A collection of structlog processors for prettier output
Project description
A collection of structlog processors for prettier output: a code syntax highlighter, JSON and XML prettifiers, a multiline string printer, and a numeric value rounder.
Installation
First of all, sorry, grandma, but structlog-pretty requires Python 3.
You can just install the library with pip:
pip install structlog-pretty
or, if you want faster prettifying processors:
pip install structlog-pretty[fast]
The downside of the faster processors is that they will build C extensions and they need libxml to be installed.
Usage
Add structlog-pretty processors to your structlog configuration
import structlog
import structlog_pretty
structlog.configure(
# ...
processors=[
structlog.stdlib.add_log_level,
structlog_pretty.NumericRounder(digits=2, only_fields=['timing'])
structlog.processors.JSONRenderer(),
],
)
A nice example of a processor pipeline for the prettiest logs could be
processors=[
# ...
structlog_pretty.JSONPrettifier(['request', 'response']),
structlog_pretty.XMLPrettifier(['soap_response']),
structlog_pretty.PathPrettifier(),
structlog_pretty.SyntaxHighlighter({'request': 'json', 'response': 'json', 'soap_response': 'xml'}),
structlog_pretty.MultilinePrinter(['request', 'response', 'soap_response']),
# ...
],
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
Built Distribution
File details
Details for the file structlog_pretty-0.4.2.tar.gz
.
File metadata
- Download URL: structlog_pretty-0.4.2.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.25.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd470a9f23c333d9e3648d598f94f104fa1cd1df0832fa02e5a953a5b9ad5840 |
|
MD5 | 5bd24580130029328f9efc85d3d9a53e |
|
BLAKE2b-256 | 6374503ae24f3ecffc6bbbc4c759d8430fb4fc1a28bde354d335559e5c6bc4bb |
File details
Details for the file structlog_pretty-0.4.2-py3-none-any.whl
.
File metadata
- Download URL: structlog_pretty-0.4.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.25.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67d860d4a2c4f97e2efd6c8b18458bb25f884427cf7ca7438f3977583a7d8560 |
|
MD5 | c2691b2611aa8f5224c4f4384800a6cc |
|
BLAKE2b-256 | 3e5b2c21dc6c1aeccae38de7ec3acc39b9223d59a93e6897bfe775039b6768b9 |