A simple logging library with JSON log formatting
Project description
Logtron
Logtron is a simple logging library with JSON log formatting.
>>> import logtron
>>> logger = logtron.autodiscover()
>>> logger.info("hello world")
{"timestamp": 1598900664859, "message": "hello world", "name": "root", "level": 20, "context": {}, "extra": {}}
>>> logger.info("extra args", extra={"foo": "bar", "count": 7})
{"timestamp": 1598900667704, "message": "extra args", "name": "root", "level": 20, "context": {}, "extra": {"foo": "bar", "count": 7}}
>>>
Or
>>> import logtron
>>> logtron.autodiscover() # Only needs to run once somewhere to configure the root logger
<RootLogger root (INFO)>
>>>
>>> import logging
>>> logger = logging.getLogger()
>>> logger.info("hello world")
{"timestamp": 1598900735699, "message": "hello world", "name": "root", "level": 20, "context": {}, "extra": {}}
>>> logger.info("extra args", extra={"foo": "bar", "count": 7})
{"timestamp": 1598900757238, "message": "extra args", "name": "root", "level": 20, "context": {}, "extra": {"foo": "bar", "count": 7}}
>>>
Logtron allows you to skip all the usual boilerplate when configuring python logging.
Logtron will default to a console JSON log formatter that is compatible with popular log aggregators such as Logstash, Fluent Bit, or AWS CloudWatch Logs.
Installing Logtron and Supported Versions
Logtron is available on PyPI:
$ python -m pip install logtron
Logtron officially supports Python 2.7 & 3.5+.
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
logtron-0.1.15.tar.gz
(9.4 kB
view hashes)
Built Distribution
Close
Hashes for logtron-0.1.15-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce4dce9fe93a42be8380ed90e164ddc8d6f00971116876f2d4c3baddfee2b642 |
|
MD5 | 27d0c2d571f71343f6efcf97c12069ff |
|
BLAKE2b-256 | 24b8e74ca9fcfbd6900724a329c46d535fa4967bbb03b1140cf2a92425993318 |