ilija1 / logtron

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logtron

Release Downloads Supported Versions License

Build Coverage Documentation Maintainability Tech Debt Issues

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+.

For more info, check out the documentation.

About

License:Apache License 2.0


Languages

Language:Python 41.7%Language:SCSS 32.1%Language:Vue 14.4%Language:JavaScript 9.1%Language:Makefile 2.8%