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 support for setting levels to hooks #11

Open
montanaflynn opened this issue Apr 1, 2019 · 2 comments
Open

Add support for setting levels to hooks #11

montanaflynn opened this issue Apr 1, 2019 · 2 comments

Comments

@montanaflynn
Copy link

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
Copy link
Owner

onrik commented Apr 11, 2019

What is your cases for change levels after hook created?

@montanaflynn
Copy link
Author

@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

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

No branches or pull requests

2 participants