onrik/logrus

Add support for setting levels to hooks

montanaflynn opened this issue · 2 comments

I would like to use filename hook but only for errors, other hooks I use (logrus_sentry, logrus-papertrail-hook) expose a SetLevels method for this like so:

hook.SetLevels([]logrus.Level{
	logrus.PanicLevel,
	logrus.FatalLevel,
	logrus.ErrorLevel,
})
logger.AddHook(hook)
onrik commented

What is your cases for change levels after hook created?

@onrik my use case is wanting to only include the filename for certain levels.

I found a pattern in other hooks that support the SetLevels method so I assumed that was not supported but now that I looked at the code I see that NewHook takes levels as an arg.

Maybe you could add links to godoc to help others as well:

https://godoc.org/github.com/onrik/logrus/filename