feat(logger): Custom console formatter for JSON and multiline strings#1442
Merged
afjcjsbx merged 2 commits intosipeed:mainfrom Mar 14, 2026
Merged
feat(logger): Custom console formatter for JSON and multiline strings#1442afjcjsbx merged 2 commits intosipeed:mainfrom
afjcjsbx merged 2 commits intosipeed:mainfrom
Conversation
mengzhuo
reviewed
Mar 13, 2026
| }) | ||
| } | ||
|
|
||
| func formatFieldValue(i any) string { |
Collaborator
There was a problem hiding this comment.
Can you add a test against this function?
alexhoshina
approved these changes
Mar 14, 2026
This was referenced Mar 15, 2026
dj-oyu
pushed a commit
to dj-oyu/picoclaw
that referenced
this pull request
Mar 16, 2026
…tting feat(logger): Custom console formatter for JSON and multiline strings
j0904
pushed a commit
to j0904/picoclaw
that referenced
this pull request
Mar 22, 2026
…tting feat(logger): Custom console formatter for JSON and multiline strings
andressg79
pushed a commit
to andressg79/picoclaw
that referenced
this pull request
Mar 30, 2026
…tting feat(logger): Custom console formatter for JSON and multiline strings
ra1phdd
pushed a commit
to ra1phdd/picoclaw-pkg
that referenced
this pull request
Apr 12, 2026
…tting feat(logger): Custom console formatter for JSON and multiline strings
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
Implemented a custom
FormatFieldValuefunction within thezerolog.ConsoleWriter.This change intercepts and correctly formats multiline strings and complex JSON objects, which
zerologby default converts to byte arrays ([]byte) or escaped strings. This also fixes the issue where tool arguments in logs were being printed as raw byte arrays instead of readable JSON. The overall goal is to significantly improve Developer Experience (DX) and log readability during terminal debugging.🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
📚 Technical Context (Skip for Docs)
zerologlogs structured fields or complex JSON to theConsoleWriter, it serializes them into byte arrays or adds escape sequences. The new customFormatFieldValueunquotes strings, restores actual line breaks in the terminal, and preserves the formatting of JSON blocks, making the stdout output much more human-readable. It specifically addresses the unreadable output ofargsin theToolRegistry.ExecuteWithContextlogs.🧪 Test Environment
Click to view Logs/Screenshots
❌ BEFORE (Without Custom Formatter):
Newlines are printed as literal text, internal JSON is escaped, and tool arguments are printed as raw byte arrays.
✅ AFTER (With Custom Formatter):
Strings break into new lines correctly, JSON objects retain their clean original characters, and tool arguments are fully readable.
☑️ Checklist