I am not happy with "Logging in a Library"
http://docs.python-guide.org/en/latest/writing/logging/#logging-in-a-library
The following snippet is too long for my eyes:
# Set default logging handler to avoid "No handler found" warnings.
import logging
try: # Python 2.7+
from logging import NullHandler
except ImportError:
class NullHandler(logging.Handler):
def emit(self, record):
pass
logging.getLogger(__name__).addHandler(NullHandler())
I guess only very few people need to support Python<2.7 today. I think a guide for new comers should use the pattern like this:
import logging
logging.getLogger(__name__).addHandler(logging.NullHandler())
My goal: less is more. Too much code confuses new comers.
I am not happy with "Logging in a Library"
http://docs.python-guide.org/en/latest/writing/logging/#logging-in-a-library
The following snippet is too long for my eyes:
I guess only very few people need to support Python<2.7 today. I think a guide for new comers should use the pattern like this:
My goal: less is more. Too much code confuses new comers.