Skip to content

feat(client): add logPrefix option to SorokitClientConfig #257 - #346

Merged
Just-Bamford merged 1 commit into
Sorokit:mainfrom
gitGolf:fix/257-log-prefix
Jul 29, 2026
Merged

feat(client): add logPrefix option to SorokitClientConfig #257#346
Just-Bamford merged 1 commit into
Sorokit:mainfrom
gitGolf:fix/257-log-prefix

Conversation

@gitGolf

@gitGolf gitGolf commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR adds a logPrefix option to SorokitClientConfig so consumers running multiple client instances (e.g. one per network) can distinguish which client emitted each log line.

Related Issue

Closes #257

Changes

🔏 logPrefix Config Option

  • [ADD] logPrefix?: string to SorokitClientConfig in src/client/createSorokitClient.ts

    • Passed as prefix to createLogger when no custom logger is provided.
    • Ignored when a custom logger is supplied.
  • [ADD] prefix?: string to LoggerOptions in src/shared/logger.ts

    • Applied as the first argument to console.debug/info/warn/error (default: "[sorokit]").
    • Enables distinct prefixes like [app:testnet] or [sorokit:mainnet].
  • [ADD] Tests in src/tests/logger.test.ts

    • createLogger({ prefix: "[sorokit:testnet]" }) emits with the custom prefix.
    • createSorokitClient({ debug: true, logPrefix: "[app:testnet]" }) logs with the custom prefix.

Verification Results

npm test -- src/tests/logger.test.ts
✅ 14/14 passed

npm test -- src/tests/client.test.ts
✅ 36/36 passed
Acceptance Criteria Status
SorokitClientConfig has logPrefix?: string
createLogger accepts an optional prefix ✅ via LoggerOptions.prefix
createSorokitClient({ network: "testnet", debug: true, logPrefix: "[app:testnet]" }) logs with custom prefix ✅ Verified via console spy
Test verifies the prefix appears in log output
Existing logger tests pass

@Just-Bamford
Just-Bamford merged commit 55712f1 into Sorokit:main Jul 29, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SorokitLogger Has No logPrefix Option — Multiple Client Instances Cannot Be Distinguished in Debug Logs

2 participants