make logger more clear with highlight component and use package name for default component#2154
make logger more clear with highlight component and use package name for default component#2154yinwm merged 1 commit intosipeed:mainfrom
Conversation
…for default component
yinwm
left a comment
There was a problem hiding this comment.
LGTM, nice improvement to log readability! The yellow component highlight and auto package name fallback make logs much easier to scan.
A few non-blocking suggestions for future consideration:
-
The hardcoded ANSI code in
FormatPrepare(\x1b[33m) doesn't check if stdout is a TTY. When output is piped or redirected, the escape codes will appear as garbage. Consider checkingterm.IsTerminal(int(os.Stdout.Fd()))or the ConsoleWriter'sNoColorfield. -
getPackageNameFromFilereturns"."when called from a file in the project root (e.g.,main.go). A special case for"."returning something like"main"would be cleaner. -
Consider adding unit tests for
getPackageNameFromFileto cover normal paths and edge cases.
None of these block merging — the change is clean and well-scoped. 🚀
make logger more clear with highlight component and use package name for default component
make logger more clear with highlight component and use package name for default component.
detail see screenshot
📝 Description
🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
📚 Technical Context (Skip for Docs)
🧪 Test Environment
📸 Evidence (Optional)
Click to view Logs/Screenshots
☑️ Checklist