Skip to content

Keep ANSI colors out of pretty transport lines (#375) - #376

Merged
terehov merged 1 commit into
masterfrom
development
Sep 11, 2026
Merged

Keep ANSI colors out of pretty transport lines (#375)#376
terehov merged 1 commit into
masterfrom
development

Conversation

@terehov

@terehov terehov commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

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 fileTransport on a pretty logger wrote color codes into the log file (the same for HTTP, ring-buffer and custom sinks, and for an explicit format: "pretty"). It only came out clean when stdout was piped, because pretty.style follows the console's TTY.

Change

  • The pretty() format stage (the only path transports use) renders from a copy of the settings with style: false, so a transport's pretty line is always plain text. The copy includes inspectOptions, so the logger's own settings and console colors are untouched.
  • The tslog CLI pretty-printer calls prettyFormatLine directly and keeps coloring on a TTY.
  • Regression tests in tests/41_issue_fixes.test.ts: an attached transport on a styled logger, an explicit format: "pretty", and an end-to-end fileTransport run matching the report. All fail against the old code; one also guards that console styling survives.
  • README transport section, 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.

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (99875bf) to head (e90396c).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@terehov
terehov merged commit 1433c2c into master Sep 11, 2026
21 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.

Feature Request: Hide the color character

1 participant