Lumberpy is an easily configurable python3 module for advanced logging use cases
The config format is based on the (python standard lib dict config format)[https://docs.python.org/3/howto/logging-cookbook.html#an-example-dictionary-based-configuration]. There are a few extra keys and more defaults.
"{asctime} {levelname:3.3} {name}: {message}"
Example:
Reasoning:
Applications using lumber usually have three ways to configure logging:
-v
to set log leve to DEBUG
)If several are provided precedence in that order. For example:
-v
is provided log level from config file and via environment variable, the later two are ignoredThe following variables are available
LUMBER_CONFIG_PATH
load config from provided pathLUMBER_LEVEL
sets the log level, (e.g. DEBUG or as integer 1 to 60)LUMBER_FORMAT
to set the default log format.import lumberpy
LOG = logging.getLogger(__name__)
@click.command()
@click.option('--lumberpy-config-path', type=click.Path())
@click.option('-v', '--verbose', count=True)
def main(lumberpy_config_path, verbose):
"""Console script for python_boilerplate."""
lumberpy.setup(lumberpy_config_path, verbose)
LOG.warning("A waring")
return 0
With the main goal of lumberpy being to cut down on boilerplate there is an even shorter way to add the click options:
import lumberpy.click
@click.command()
@lumberpy.click.options()
def main(lumberpy_config_path, verbose):
lumberpy.setup(lumberpy_config_path, verbose)