Supplements a default formatter configuration for machine-readable JSON logging and applies it
Project description
python-logger
Supplements a default formatter configuration for machine-readable JSON logging and applies it.
This module should be included as a sub-module in python projects with logging. Please avoid copy-pasting as no updates can be supplied that way.
Usage
- Please first include the
PythonLogger
module, using afrom module import class
statement. - After the imports, please declare a version constant.
This constant should use semantic versioning, with a prepended date(YYYY/MM/DD)
.
Other examples, without the date, can be found here - Before any argument parsing or any other logging, the logger should be initialized
- In EVERY file, the logger needs to be imported using
LOGGER = logging.getLogger(__name__)
from python_logger import PythonLogger
import logging
VERSION = "1.0.0 (2022/11/24)"
PythonLogger.setup_logger(VERSION)
LOGGER = logging.getLogger(__name__)
Optionally, it is also possible to change the log level:
from python_logger import PythonLogger
import logging
VERSION = "1.0.0 (2022/11/24)"
PythonLogger.setup_logger(VERSION, logging.DEBUG)
LOGGER = logging.getLogger(__name__)
Features
Sets the logging format for the root logger and thus for every child logger.
In EVERY file where logging happens, please use LOGGER = logging.getLogger(__name__)
to get an individual logger.
Allows printing exception information on any logging level, not only on the EXCEPTION
level but also for INFO
or DEBUG
.
Supply exec_info
to print these.
Sets pipeline_status
and job_status
to failed
on ERROR
or CRITICAL
, supports minor logging levels (41, etc).
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
Built Distribution
Hashes for python_json_log_formatter-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76d4211ccae356ae7f4d1b6f61e3fe6675b954d2b1bb1d099719d038e3bf1f3c |
|
MD5 | 75fdcd3d1776bbc23da3e0c09eec2ad0 |
|
BLAKE2b-256 | e210afefffe3871bbfbb0e9fc31d0a6e5af26741a040776a171b241ac971d057 |
Hashes for python_json_log_formatter-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e339cd8be222c499f6f0e7dc2dc63603cd24331f36f6240089cf0350e7a0722 |
|
MD5 | 75f340a464de845feaf425fe0563de91 |
|
BLAKE2b-256 | 3aa7841bf9cc300c732c7a82f7659f296bf03d6478e825e672fc11b8ce9014b2 |