sharklog

A Python logging helper


Keywords
logging, helper
License
Other
Install
pip install sharklog==0.0.2

Documentation

sharklog

Python logging helper.

PyPI License PyPI Version

Quick Start

  • Install sharklog:
python -m pip install sharklog
  • Use in standalone script:
# standalone.py
from sharklog import logging

logging.init(debug=True)
logging.debug("debug message")
logging.info("info message")
logging.warning("warning message")
logging.error("error message")
  • Use in module:
# submodule.py which is placed under package `parent`
from sharklog import logging

logger = logging.getLogger()    # the logger name will be `parent.submodule`

logger.debug("debug message")
logger.info("info message")
logger.warning("warning message")
logger.error("error message")

If you already using builtin logging module, you can use sharklog as a drop-in replacement.

Just change import logging into from sharklog import logging. Then you can use logging as usual:

# module_name.py
from sharklog import logging

# these log messages will be prefixed with the logger name `xxxpackage.xxmodule.module_name`
logging.debug("debug message")
logging.info("info message")
logging.warning("warning message")
logging.error("error message")

Usage in Package Development

# parent/__init__.py
from sharklog import logging

logging.getLogger().addHandler(logging.NullHandler())