python logging json formatter
Project description
log-json-fmt
python logging json formatter.
Installation
$ pip install logjsonfmt
---> 100%
Example
Create it
- Create a file
example.py
with:
import logging
import logjsonfmt
logger = logging.getLogger()
logHandler = logging.StreamHandler()
formatter = logjsonfmt.JSONFormatter(hostname="app.example.com", indent=True)
logHandler.setFormatter(formatter)
logger.addHandler(logHandler)
logger.error('hello world!', extra={"tags": ["app=helloworld"]})
Out:
{
"@timestamp": "2021-05-27 03:03:01.745983 +00:00",
"app_host_name": "app.example.com",
"logger_name": "root",
"level": "ERROR",
"pathname": ".\\example.py",
"lineno": 17,
"func_name": "<module>",
"thread_id": 30612,
"thread_name": "MainThread",
"process_id": 7356,
"process_name": "MainProcess",
"message": "hello world!",
"tags": [
"app=helloworld"
]
}
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
logjsonfmt-0.0.1.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for logjsonfmt-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6214b6fbb388faa05a28b73ac00bb0d5f3ab3399cb1e1411902d16a3cf1401a3 |
|
MD5 | 53dab62f27b54115958c71b40bf34e6d |
|
BLAKE2b-256 | 12e808974cbcb6e84149bea79d9ff70e33ca4b0927075c171259aaf7c8e16ee6 |