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
- Install the module via the
requirements.txt
or per CLI:pip install python-json-log-formatter
- Please 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-2.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba8ced46e1a1c7296a2d69719a5a8316eba737a043b04cca937d364f2a8d806c |
|
MD5 | 6a12bc1216cd44434f23ad5a001e26e0 |
|
BLAKE2b-256 | 72911d7aba40b7c46cefab3ef10fa81d9c45ece09fd2d6007df75404217fdd00 |
Hashes for python_json_log_formatter-2.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe0af6766422595fe7bd32f066886f1b265ab15da8a22ff07bceb13834e3a6ee |
|
MD5 | b3129c882c28d7cb350eeb00e6ca9e4a |
|
BLAKE2b-256 | 4269c5ce38a168c1f42665ee7cc52b9248e9ef054fe34c65f6d52c6412eaae68 |