Skip to content

fix: disable ANSI color codes in test logger file output#245

Closed
gumruyanzh wants to merge 1 commit intojetzig-framework:mainfrom
gumruyanzh:fix-test-logger-file-output
Closed

fix: disable ANSI color codes in test logger file output#245
gumruyanzh wants to merge 1 commit intojetzig-framework:mainfrom
gumruyanzh:fix-test-logger-file-output

Conversation

@gumruyanzh
Copy link

Summary

  • Fix raw ANSI escape codes being written to log/test.log
  • Colorization is now only enabled when writing to stderr, not to log files

Problem

The test logger's logRequest() was hardcoding colorized = true for method formatting, duration, and status code formatting. When writing to log/test.log (file mode), this embedded raw ANSI escape sequences like \x1b[33m into the file, making it garbled and hard to read.

Example corrupted output in log/test.log:

gger: INFO [DELETE|7.438ms|200 OK] /containers/1
[33m1.784ms|200 OK] /containers/1

Fix

Derive colorized from the output mode: const colorized = self.mode == .stream. When the test logger writes to stderr (stream mode), ANSI codes are used. When writing to a file, plain text is written.

Test plan

  • zig build succeeds
  • zig build test --summary all - all 75 tests pass

Fixes #172

🤖 Generated with Claude Code

The test logger's logRequest() was passing colorized=true regardless of
the output target, causing raw ANSI escape codes (e.g. \x1b[33m) to be
written to log/test.log. This made log files hard to read and appeared
as garbled output.

Now colorization is only enabled when writing to stderr (stream mode),
not when writing to a log file.

Fixes #172

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@gumruyanzh gumruyanzh closed this by deleting the head repository Feb 27, 2026
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.

Test logger not syncing to disk or flushing?

1 participant