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.2.tar.gz
(3.4 kB
view details)
Built Distribution
File details
Details for the file logjsonfmt-0.0.2.tar.gz
.
File metadata
- Download URL: logjsonfmt-0.0.2.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.24.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79470cab4ab6265ad5a8104bbf43192a563d861c927615fe853382c83a507421 |
|
MD5 | 31f3a99ed35dac0c0433508ba7b6f50c |
|
BLAKE2b-256 | de861faf00a3aa58d659c273760fbf9525d8db9473f74d8d44e924a4e88f8423 |
File details
Details for the file logjsonfmt-0.0.2-py2.py3-none-any.whl
.
File metadata
- Download URL: logjsonfmt-0.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.24.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 026d470b567327114b0bbe6730ca4713094ac54eb0ae3ccafd49597f4d956470 |
|
MD5 | 0072e9d2ce209a325ececcfdd4c1138a |
|
BLAKE2b-256 | 980c4a2bba0ea31cac7b4794d42d3e1eed6f93d3c7c20da62f6f2ae19736ed8a |