Make practical Python logging easy.
pip install happy-python-logginghappy_python_logging.getLoggerForLibrary()
-import logging
+from happy_python_logging import getLoggerForLibrary
-logger = logging.getLogger(__name__)
-logger.addHandler(logging.NullHandler())
+logger = getLoggerForLibrary(__name__)See example for detail.
happy_python_logging.lib.filters.OrFilter
import logging
from happy_python_logging.lib.filters import OrFilter
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
stream_handler.addFilter(OrFilter("libA", "libB"))
root_logger.addHandler(stream_handler)DEBUG | libA:libA_awesome:8 - awesome
DEBUG | libB:libB_fabulous:12 - fabulous
You can combine OrFilter with logging.Filter using the | operator:
OrFilter("libA", "libB") | logging.Filter("app.important")
# reverse order also supportedhappy-python-logging is distributed under the terms of the MIT license.