feat:Replace the uniform 'info' with accurate log levels in the information output from the log#353
Merged
soltanoff merged 1 commit intoevrone:masterfrom Dec 7, 2025
Merged
Conversation
…tion output from the log
Collaborator
|
Looks good to me, thank you! Before merge, I'll test (or add some test cases) for debug/war/error logs. It would be nice if you can add it. |
There was a problem hiding this comment.
Pull request overview
This pull request fixes a critical bug in the logging system where all log calls (Debug, Warn, Error, Fatal) were incorrectly outputting logs with the "info" level. The fix updates the internal logger methods to accept and use zerolog.Level types instead of hardcoded string values, ensuring each log method now outputs with its correct corresponding level.
Key Changes:
- Modified
log()andmsg()helper functions to acceptzerolog.Levelparameter instead of string - Updated all public logging methods (
Debug,Info,Warn,Error,Fatal) to pass appropriatezerolog.Levelconstants - Changed from hardcoded
.Info()calls to dynamic.WithLevel(level)calls in the logger implementation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
This update focuses on optimizing the precision of log levels in output. It addresses the issue where all log calls (e.g.,
log.Debug/log.Warn) were uniformly mapped to theinfolevel in the original logging system. By correcting the log level mapping logic, each log call type now corresponds to its actual intended level, resolving the problem of ambiguous log hierarchy and inability to distinguish the importance of information.Example of Original Log Issue
The original logging system had incorrect level mapping—regardless of whether
log.Debugorlog.Warnwas called, the output was always marked asinfo, leading to mixed log types:Example 1:
Output incorrectly showed:
{"level":"info","time":"2025-11-30T15:15:49+08:00","caller":"/work/src/cards/application.go:107","message":"hello"} // Debug info incorrectly labeled as infoExample 2:
Output still showed:
{"level":"info","time":"2025-11-30T15:15:49+08:00","caller":"/work/src/cards/application.go:107","message":"[callback]NextChar: "} // Warning info incorrectly labeled as infoThis incorrect mapping mixed debug details, warning prompts, and normal process information, significantly reducing the filtering value of logs and efficiency in issue troubleshooting.
Optimized Examples & Explanation
After fixing the log level mapping logic, log call types now accurately match the output levels:
Warning Calls (
log.Warn):Output corresponds to the
warnlevel to highlight risk prompts:{"level":"warn","time":"2025-11-30T15:29:53+08:00","caller":"/work/src/router.go:158","message":"appId:[1] is not exist, use default appid"}Debug Calls (
log.Debug):Output corresponds to the
debuglevel to retain troubleshooting details:{"level":"debug","time":"2025-11-30T15:29:53+08:00","caller":"/work/src/router.go:162","message":"[fi..."}Post-optimization, log levels fully align with the actual type of information. This enables quick filtering of warning risks, debug details, or core process information by level, greatly improving log analysis efficiency and accuracy in issue localization.