splunk / splunk-sdk-python

Splunk Software Development Kit for Python
http://dev.splunk.com
Apache License 2.0
698 stars 370 forks source link

Use module-specific logger in library code instead of root logger #337

Closed majiang closed 2 years ago

majiang commented 4 years ago

This pull request is to comply with Advanced Logging Tutorial:

A good convention to use when naming loggers is to use a module-level logger, in each module which uses logging, named as follows:

logger = logging.getLogger(__name__)

This pull request is also almost identical to #94 which I'm not sure why was closed.

delewis13 commented 4 years ago

+1 on this, using this module is adding a stream handler to my root level logger, which subsequently causes all my logging statements in the rest of my application to output multiple lines.

majiang commented 4 years ago

Hi Splunk team, do you have any comments, thoughts or ideas about failing CI?

RCoff commented 3 years ago

I definitely need this. The logs from 'binding.py' are unnecessary for me and only serve to clog up my Splunk index.

ashah-splunk commented 2 years ago

@majiang as per your suggestion, we have added module specific logger along with an utility to enable loggers for different levels as well. Please refer the README. The changes are available in the latest release 1.6.19

majiang commented 2 years ago

Thanks! It's #437, for reference