-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Allow specifying user defined log level names #1277
Comments
Internal Ref: GO-2011 |
Can I work on this ? @JacobOaks |
Of course! Feel free to open a PR. |
Sorry I hopped late onto this thread, but I believe we shouldn't add this feature to Zap. Allowing definitions of custom levels is a breaking change and we do not want that. See the discussions in #680. Existing encoders and samplers could break due to such things. For example: #713 is an example of someone defining their own custom log level which broke the sampler. |
Is your feature request related to a problem? Please describe.
As a user of
zap
I'd like to define my own custom log level, let's call itTraceLevel
. It's destined to be more verbose than Debug.Because currently the log levels are checked against a known, concrete set of values
zap/zapcore/level.go
Lines 134 to 156 in 4451b47
All I can get is
fmt.Sprintf("LEVEL(%d)", l)
Describe the solution you'd like
Define an interface that user defined log levels can be checked against and if they implement it then use it to get the name of the log level.
If that fails then resort to
fmt.Sprintf("LEVEL(%d)", l)
.Describe alternatives you've considered
None exist to the best of my knowledge.
Is this a breaking change?
No.
The text was updated successfully, but these errors were encountered: