-
Notifications
You must be signed in to change notification settings - Fork 442
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
Added support for setting logger for each log level #275
Conversation
@crazyweave can you describe what your use case is for this change? |
I was debugging the unusual number of high priority tickets generated from go-nsq and determined that instead of only error logs generating tickets, every log message being logged (given a logging level) generates a ticket. The root of our issue was an incorrect assumption regarding the behavior of This PR enables package consumers to employ a more nuanced approach to setting up logging for go-nsq. This allows us to redirect error log messages to get the right attention while routing all other log messages elsewhere - including suppressing them by not setting a logger for that log level. |
I think that, if we are to go forward with this, we should keep more compatibility for existing public methods. |
@ploxiln Sounds perfectly reasonable. |
I've pulled the latest changes from master and made the requested changes. |
@ploxiln Thanks for reviewing this. Do you see anything else or have any more concerns? |
Nope, I don't see anything else, looks fine to me. I'm not really one of primary authors of this component, so I'll give @jehiah a bit more time to comment. One last little thing though, can you squash down to one commit? Thanks :) |
I’ve added support for using separate loggers for each level. I tried to minimize the changes required to existing code and maintain as much backwards compatibility as I could.
The change required to existing code is the requirement to add a call to
SetLoggingLevel()
if the default level (LogLevelInfo
) is not the desired level. Previously the call toSetLogger()
would do this implicitly.This change also expands the API surface by 1 with a convenience function
SetLoggerForLevels()
that sets the same logger for the levels provided as parameters. This convenience function simplifies achieving the previous behavior of using just one logger for all levels.