This project has been archived by its maintainers, and is no longer receiving any updates.
This is a fork of simple_json_logger, extracting the formatter into it’s own project.
It formats the Python logging.Record into a JSON suitable for indexing engines like Logstash and AWS CloudWatch Logs.
Installation
pip install simple_json_log_formatter
Usage
Simply set the formatter in a log handler and add it to the current logger.
For example, to print the JSON logs to the current stream, set up the logger with the following:
import json, logging
from simple_json_log_formatter import SimpleJsonFormatter
handler = logging.StreamHandler()
handler.setFormatter(SimpleJsonFormatter(json.dumps))
logging.getLogger().addHandler(handler)
logging.getLogger().setLevel(logging.INFO)
And then simply call logging.info('TEST'). It should print something like this:
{"timestamp": "2017-09-08T17:01:26.408975", "line_number": 1, "function": "<module>", "module": "<input>", "level": "INFO", "path": "<input>", "msg": "TEST"}
Testing
python setup.py test
Compatibility
Python versions 2.7 and 3.4+ are supported.
Metadata
Release files for simple-json-log-formatter 0.5.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| simple_json_log_formatter-0.5.5-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Release files / simple_json_log_formatter-0.5.5-py2.py3-none-any.whl
| Download URL | simple_json_log_formatter-0.5.5-py2.py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ae776eb7a7895618d8c539e975f1ad4bc283266cfa9257984336a3686d446a3b
|
|
BLAKE2b-256 checksum How to use checksums |
f6905926949eea96725821e5ae78308dd7063fd231376e00367a97afa695cc7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Security for simple-json-log-formatter 0.5.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.