out-of-the-box, ready-to-use JSON logger
Project description
jonson
![](https://pypi-camo.freetls.fastly.net/6a41216c56f4c83ba1aa44125f6cf61070f9f0b3/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d676974687562266d6573736167653d6a6f6e736f6e266c6162656c436f6c6f723d626c61636b26636f6c6f723d333537326135267374796c653d666c61742d737175617265266c6f676f3d676974687562)
out-of-the-box, ready-to-use JSON logger
from jonson import logger
logger.info("Something going as expected", { "host": socket.gethostname() })
logger.warn("Something must have gone terribly wrong")
except Exception as e:
logger.error(e, { description: "something descriptive" })
Log level
Create logger instance with a minimal log level
from jonson import Logger
logger = Logger("warn")
logger.info("Something going as expected", { "host": socket.gethostname() }) # ignored
logger.warn("Something must have gone terribly wrong") # sent
Log levels hirarchy
A few synonyms are available for convenience
trace
,verbose
debug
info
,log
warn
error
critical
,fatal
,panic
For example, a logger with log level "warn" will only print logs with level "warn", "error", or "critical".
Arguments
Create: Logger class accepts one or two arguments:
{string}
Case insensitive name of minimal log level. defaults to"info"
{dictionary}
{'Key':'Value'} pairs, optional. Persistent enrichment fields for all log records
logger = Logger(os.environ["LOG_LEVEL"], { "host": socket.gethostname() })
Send: Logger functions accept one or two arguments:
{any}
Record's "message" field. Traditionally this would be a string or an exception.{dictionary}
{'Key':'Value'} pairs, optional. Values should be JSON serializable
logger.info("something, something", { dark: "side" })
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
jonson-1.1.1.tar.gz
(3.7 kB
view hashes)
Built Distribution
jonson-1.1.1-py3-none-any.whl
(4.0 kB
view hashes)