-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Custom Log Levels #463
Comments
@yoiang Do you have a proposal for how this would work? |
hey @stevvooe! Do you mean what would the API look like or how would it actually be implemented in logrus' guts technically? I am not expert with either but can take some time and figure it out depending on what you're asking! |
I suggest simply exposing Then we can all simply create levels via: const TraceLevel = logrus.DebugLevel + 1
func init() {
logrus.SetCustomLevelName(TraceLevel, "trace")
} This of course does not solve issues where people may want their level in between other levels. The way to solve that with a backwards compatible impl is to keep the type Leveler interface {
Cmp(other Leveler) int
LevelString() string
}
func (level Level) Cmp(other Leveler) int {
switch other := other.(type) {
case Level:
if level > other {
return 1
} else if level < other {
return -1
}
return 0
default:
return -other.Cmp(level)
}
}
func (level Level) LevelString() string { return level.String() } Then of course have |
@cretz Would it be sufficient just to add a |
@stevvooe See you here! :D @cretz I agree with you. In Kubernetes, we usually have:
In cri-containerd, we were using |
+1 for custom log levels |
+1 |
+1 for user implemented log levels. A use case that we use a lot that might not have been considered is Cloudwatch Log filtering into Cloudwatch Metrics. In most languages we create a log level called |
FWIW @defendertx's comment is exactly the reason I found this issue by searching "logrus custom level" in Google |
+1 for custom log levels |
Logrus now (and for a while) has had a Additionally there are I think the only thing missing is the way that existing levels are somewhat hard coded, making extension / customization of them a bit hard. Related to that: #1009 (comment) |
Suddenly I think Trace level fits most of needs but not all. For example custom log levels could be useful also for audit logging, suddenly with current log levels it's very complex to find place for them, and creating custom log level for them could be a good option |
Closing per the project being put into maintenance mode |
Hello logrus folks!
It was mentioned in issue #121 that being able to make your own custom log levels would be a feature by 1.0, wanted to make a place to track the feature's progress.
Thanks for the great work!
The text was updated successfully, but these errors were encountered: