- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.7k
Fix formatting of remote debug logs #2464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Fix formatting of remote debug logs #2464
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @HugoW5 Thanks for the PR — this is a useful quick fix.
But we should avoid using IsTerminal() or a type-assertion in the filter; since it duplicates terminal vs JSON formatting and can leak ANSI into JSON logs.
A cleaner approach could be we can add a small typed message in remotelogger (for example httpDebugMsg) that:
- Implements logging.PrettyPrintto render ANSI-colored output for terminals.
- Implements json.Marshaler / MarshalJSONto return an ANSI-free string for JSON/file logs.
- Replace the Debugf(...) branches with a single f.Logger.Debug(msg) call, passing the httpDebugMsg instance.
| @Umang01-hash | 
| @HugoW5 Any update on this? | 
| @Umang01-hash Have been busy, will start later today! | 
| I’ve implemented the improved solution we discussed: Replaced  
 
 This fully fixes the ANSI leakage issue (#2281) and keeps terminal logs colored while JSON remains parseable. Logs are verified: JSON output is clean, and terminal output retains colors. | 
Description:
isTerminalLogger()tohttpLogFilterto detect if the underlying logger writes to a terminalIsTerminal()on the base logger to allow querying terminal output capability.Benefits
Related Issue
Fixes #2281
Additional Information:
Checklist:
goimportandgolangci-lint.