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
Built Distribution
File details
Details for the file json_line_logger-0.0.9.tar.gz
.
File metadata
- Download URL: json_line_logger-0.0.9.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc9331ba784c25a2ef3b79b89d12f9efe29f7328a1bbd14abf5b097ded754fe7 |
|
MD5 | 3fd8556c05b17bd469aa2468e0fab4bc |
|
BLAKE2b-256 | 177070d1f0b509eb10146364d68c153008428140d0c25a9338c4f11f69076e1b |
File details
Details for the file json_line_logger-0.0.9-py3-none-any.whl
.
File metadata
- Download URL: json_line_logger-0.0.9-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddd209f362c6fca3e47596c4e98473e9450bdff1571913e6a3fa0748caca2819 |
|
MD5 | 4c46279d2df998ddbd15cea8e5f2b6c5 |
|
BLAKE2b-256 | 9324297f2ac0cde981b9f39d856f754e5d44e0c98d961a8340fb7c3b08342217 |