Lumberpy is an easily configurable python3 module for advanced logging use cases
Project description
Lumberpy
- Free software: MIT license
Config format
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.
- By default a colored formatter based on ... is used.
Default log format
"{asctime} {levelname:3.3} {name}: {message}"
Example:
Reasoning:
- TODO
Usage Logging configuration
Applications using lumber usually have three ways to configure logging:
- via the CLI (e.g.
-v
to set log leve toDEBUG
) - via config file (path provided by cli or environment variable)
- via environment variables
If several are provided precedence in that order. For example:
- If
-v
is provided log level from config file and via environment variable, the later two are ignored - If providing a config path via cli and via environment variable only former is used.
Environment variables
The 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.
How to include in your software
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lumberpy-0.1.0.tar.gz
(38.3 kB
view hashes)
Built Distribution
Close
Hashes for lumberpy-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6ed3ae7c23810fc14804a970feebe196750144c6b7a0d78d7481a98aff4ad10 |
|
MD5 | ae5e2c17a8634b6e9eb27bcfa3d2c0e3 |
|
BLAKE2b-256 | 07ae3538e3a5a37b89e44cba9fc7ae7f9c1796274d3247586d7b73b1af96eb6e |