Keep ANSI colors out of pretty transport lines (#375) - #376
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #376 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 53 53
Lines 4628 4632 +4
Branches 1361 1381 +20
=========================================
+ Hits 4628 4632 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fixes #375 for the 5.2.0 release.
On an interactive terminal the pretty line handed to attached transports carried the console's ANSI escape codes, so a
fileTransporton a pretty logger wrote color codes into the log file (the same for HTTP, ring-buffer and custom sinks, and for an explicitformat: "pretty"). It only came out clean when stdout was piped, becausepretty.stylefollows the console's TTY.Change
pretty()format stage (the only path transports use) renders from a copy of the settings withstyle: false, so a transport's pretty line is always plain text. The copy includesinspectOptions, so the logger's own settings and console colors are untouched.tslogCLI pretty-printer callsprettyFormatLinedirectly and keeps coloring on a TTY.tests/41_issue_fixes.test.ts: an attached transport on a styled logger, an explicitformat: "pretty", and an end-to-endfileTransportrun matching the report. All fail against the old code; one also guards that console styling survives.llms.txt, RECIPES §10 and the 5.2.0 changelog note that transport pretty lines are always plain.Browser bundle grows ~40 B gzip, within the 22,400 B budget.
Verified locally: Node (1678 tests, 100% coverage), Bun, Playwright on Chromium, build, bundle size, doc-sync, and the reporter's setup under a real pseudo-terminal.