Repository navigation
Conversation
Author
|
Confirmed working great in my expo project with a plain logger: setGlobalLogger((level, message, ...args) => {
console[level](message, ...args);
}); |
The SDK's log output always goes to `console.log` with `%c` styling, which can't be redirected to an app's own logger, and shows up as raw `%c` and CSS strings where styling isn't supported (e.g. React Native). Adds `setGlobalLogger`/`getGlobalLogger`, which receive resolved logs after the global log level is applied, and exports the existing output as `consoleLogger` (still the default). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mausworks
force-pushed
the
ts-sdk/custom-logger
branch
from
October 14, 2026 14:25
65485e0 to
82ca59e
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Changes
The TypeScript SDK's log output always goes to
console.logwith%cstyling. Only the level can be configured (setGlobalLogLevel), so there's no way to:%cstyling isn't supported. In React Native, for example, every line shows the raw%cmarkers and CSS strings.This adds a pluggable sink next to the existing level setting:
Logger:(level, message, ...args) => void. It's only called for logs that pass the global log level, with lazy messages and arguments already resolved.setGlobalLoggerandgetGlobalLogger: replace or read the current sink, mirroringsetGlobalLogLevelandgetGlobalLogLevel.consoleLogger: the existing styledconsole.logoutput, unchanged and still the default.API and ABI breaking changes
None. This only adds exports, and the default output is unchanged.
Rollback safety impact
n/a
Expected complexity level and risk
src/sdk/logger.ts.Testing
tests/logger.test.tscases:consoleLoggerrestores the default output.vitest run: all 417 tests pass. Locally,server_test_utils_wasm*.test.tscan't load because the portable datastore WASM build is missing; that's unrelated to this change.🤖 Generated with Claude Code