python logging formatter. JSONFormatter、GenericFormatter、CeleryTaskFormatter
Project description
py-logging-fmt
python logging formatter. JSONFormatter、GenericFormatter、CeleryTaskFormatter
Installation
$ pip install pylogformatter
---> 100%
Example
Create it
- Create a file
example.py
with:
import logging
from pylogformatter.json import JSONFormatter
logger = logging.getLogger()
logHandler = logging.StreamHandler()
formatter = 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
pylogformatter-0.0.1.tar.gz
(5.1 kB
view hashes)
Built Distribution
Close
Hashes for pylogformatter-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2b5de570a08cfd2be9ab4d256d69c3ed39072ac5846ce057b3ebe145c518b18 |
|
MD5 | f800edd8ab553c3a0035c39b4571be0d |
|
BLAKE2b-256 | a2515306cdcce115376eb925793e9cfd78abd3c9e62c8f3d51b7d4783bf01b50 |