-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
ddl, util: Add highlight to log #4861
Conversation
@@ -110,9 +110,30 @@ func stringToLogLevel(level string) log.Level { | |||
return defaultLogLevel | |||
} | |||
|
|||
// logTypeToColor converts the Level to a color string. | |||
func logTypeToColor(level log.Level) string { |
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.
How about change this to func logTypeToColor(type string, level log.Level) string
If type is not "highlight", return "\033".
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.
Only highlight
need to call this function and write color code.
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.
So why not call it logLevelToColor?
LGTM |
util/logutil/log.go
Outdated
@@ -123,6 +144,12 @@ func (f *textFormatter) Format(entry *log.Entry) ([]byte, error) { | |||
} else { | |||
b = &bytes.Buffer{} | |||
} | |||
|
|||
if !f.DisableColors { |
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.
Rename DisableColors to EnableColors. It will be more clear.
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.
LGTM.
I only add highlight log to highlight type.
logrus
default color only supports "[loglevel]" and "file=xxx.go" fields to have colors.I think using
highlight
to debug more easily. In order not to affect everyone's use, I add a new type.