Repository navigation
Fix | Emit JSON logs when --log-format is json - #496
Merged
Merged
Conversation
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
dag-andersen
approved these changes
Oct 7, 2026
dag-andersen
left a comment
Owner
There was a problem hiding this comment.
Wow, that bug has been around for a long time! clearly no one is using that feature haha - Great work!
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.
One more small fix 🙂
--log-format jsoncurrently has no effect: every format goes through zerolog'sConsoleWriter, which converts log events into human-readable text, sojsonproduces plain text lines rather than one JSON object per line. This PR makesjsonwrite zerolog's native JSON with a timestamp, in both normal and--debugmode.humanoutput is unchanged.
When the flag was added in d925b0a it worked, because the
ConsoleWriterwas only set up forhumanandjsonkept zerolog's default JSON logger. caf6a05 then moved the debug and human settings onto a sharedconsoleWriterand assignedlog.Logger = log.Output(consoleWriter)unconditionally, sojsonhas gone through theconsole writer ever since.
That's why the diff is bigger than the bug:
jsonneeds its own logger rather than a differently configuredConsoleWriter. Logger construction now lives innewLogger, which takes anio.Writerso both formats can be tested against a buffer.