-
Notifications
You must be signed in to change notification settings - Fork 378
Change splunklib logging #94
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
Conversation
…the root module's logger. Silence the splunklib module's logger by default.
@zach-taylor my main question is how this would interact with the logging that's done inside modular inputs and custom search commands, as they do need to have a default non-null logger. |
@itay I'm actually a bit confused about those pieces.. So my code will silence any logging performed in the splunklib module (including splunklib.searchcommands and splunklib.modularinput). My code is essentially pulled from here: https://docs.python.org/2/howto/logging.html#configuring-logging-for-a-library with the assumption that libraries should be silent unless the application using the library configures it to be otherwise. Regarding logging.py in the searchcommands module, I'm not sure what it's meant to do. It looks like it is configuring logging for the library, which according to the link above, a library should not do. Let me know if my understanding is incorrect. |
I think that's a fair question. That said, it makes sense for what those two modules end up doing. The reason that searchcommands and modularinput configure logging is to make sure that any logging the user does ends up in the right places in a Splunk installation. As opposed to the REST API portion of the SDK, those two libraries get run in the context of Splunk itself - so they need to know where to log, what format, etc, as part of their reason to exist is to make that simpler. Does that make sense? |
That makes sense. I think a fair compromise might be to remove the NullHandler stuff. That way I can still get the logger for these modules and silence them in my application. Would that work? |
@itay any thoughts? My company is also running into this issue big time, and this PR would solve it. |
@matthewsullivan-wf @zach-taylor that seems reasonable. I think we don't want to make it a NullHandler by default, but we should allow others to set it to a NullHandler if they want to (or whatever they want). Does that make sense? |
@itay sure thing. I can remove that default NullHandler. Would that make this work then? |
As long as by default it'll log out to stdout, then yes. |
@itay this should work. |
@itay quick ping :) |
I have made a couple changes to the debug logging found within the splunklib module.
Before the debug logging was going to the Python root logger, which causes recursion if I'm using the Splunk SDK to send Python debug level logs to Splunk. The splunklib module should log to its own module rather than the Python root logger. In addition I added a NullHandler to the splunklib module so its logs are, by default, not forwarded to the root logger.
If one needs to view the splunklib module's debug logs, they can do something like this:
Let me know if I missed anything here, and if something needs to be changed.
Thanks!