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.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
structlog-pretty-0.2.0.tar.gz
(5.8 kB
view hashes)
Built Distribution
Close
Hashes for structlog_pretty-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8252e459c7f74cffedc7ce8f6a20ca9173cd12b6da125f910e912ca5a7cae4e1 |
|
MD5 | 77020456bc18f11fdf2989a2bec01a3b |
|
BLAKE2b-256 | 92645d2bb1185481bc80ccb15a3a7472fd0bc388fa69dd34508819e5bea9a42a |