Configs for python's logging library to have a JSONL-log
Project description
Uses python’s awesome logging-library and configures it to write JSON-lines. In JSON-lines, each line in the log is a valid json-object. This makes the log easy to read with a machine.
install
pip install json-line-logger
usage
There are three handy constructors for loggers: LoggerFile, LoggerStream, and LoggerStdout.
import json_line_logger
logger = json_line_logger.LoggerFile(path="test.log.jsonl")
logger.debug("This is a log message")
with json_line_logger.TimeDelta(logger=logger, name="some costly task"):
result_of_a_costly_task = 1 + 1
json_line_logger.shutdown(logger=logger)
Yields a logfile test.log.jsonl which contains:
{"t":"1886-03-27T11:01:01.341", "l":"DEBUG", "m":"This is a log message"}
{"t":"1886-03-27T11:01:01.341", "l":"INFO", "m":"<TimeDelta name='some costly task' delta='2.1457672119140625e-06'/>"}
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
json_line_logger-0.0.9.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for json_line_logger-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddd209f362c6fca3e47596c4e98473e9450bdff1571913e6a3fa0748caca2819 |
|
MD5 | 4c46279d2df998ddbd15cea8e5f2b6c5 |
|
BLAKE2b-256 | 9324297f2ac0cde981b9f39d856f754e5d44e0c98d961a8340fb7c3b08342217 |