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

Add func for GetNameForLevel #8

Merged
merged 2 commits into from
Jul 18, 2022
Merged

Conversation

codenamoo
Copy link
Contributor

When set customized-output, it may the Name of the level useful rather than
the Text(colorful or not) of the level.

golog.Handle(func(l *golog.Log) bool {
                prefix := golog.GetNameForLevel(l.Level)
                pc, fn, line, _ := runtime.Caller(7)
                message := fmt.Sprintf("%s line %d (%s) (%s) %s: %s",
                        prefix, line, runtime.FuncForPC(pc).Name(), fn, l.FormatTime(), l.Message)

                if l.NewLine {
                        message += "\n"
                }

                fmt.Print(message)
                return true
})

will out like:
warn line 26 (main.main) (/home/pato/go/src/github.com/kataras/golog/_examples/customize-output/main.go) 2018/09/10 09:57: Hey, warning here

Thanks.

When set customized-output, it may the Name of the level useful rather than
the Text(colorful or not) of the level.
@codenamoo codenamoo requested a review from kataras as a code owner September 10, 2018 00:59
Copy link
Owner

@kataras kataras left a comment

Choose a reason for hiding this comment

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

Thanks @codenamoo but could you please fix the space in the doc comments of the new function you introduced?

@codenamoo
Copy link
Contributor Author

Hello @kataras, Thank you for your message. I've fix the indent and run gofmt. Please check again.
(But I worried about github diff shows changed indent for code but not comments.)
Thanks.

@kataras kataras merged commit bcb4cee into kataras:master Jul 18, 2022
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.

2 participants