Skip to content
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

Merged
merged 4 commits into from
Oct 23, 2017
Merged

Conversation

zimulala
Copy link
Contributor

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.

@@ -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 {
Copy link
Member

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".

Copy link
Member

@coocood coocood Oct 23, 2017

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.

Copy link
Member

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?

@coocood
Copy link
Member

coocood commented Oct 23, 2017

LGTM

@@ -123,6 +144,12 @@ func (f *textFormatter) Format(entry *log.Entry) ([]byte, error) {
} else {
b = &bytes.Buffer{}
}

if !f.DisableColors {
Copy link
Member

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.

Copy link
Contributor

@disksing disksing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@zimulala zimulala merged commit 07e05e8 into pingcap:master Oct 23, 2017
@zimulala zimulala deleted the zimuxia/highlight branch October 23, 2017 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants