Skip to main content

A collection of structlog processors for prettier output

Project description

CI Status Code Coverage

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


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.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

structlog_pretty-0.1.0-py2.py3-none-any.whl (8.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file structlog-pretty-0.1.0.tar.gz.

File metadata

File hashes

Hashes for structlog-pretty-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0170034302de673b64015a88fcac41cd313a4e4e2146fd3c62f70768ac749d45
MD5 0142b0f516f2f9558588f82346f8ed0b
BLAKE2b-256 662661ce62923d772d1289282c83b44ae15d290d0acdfeb5de04133e40f1c19e

See more details on using hashes here.

File details

Details for the file structlog_pretty-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for structlog_pretty-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9f27ea9dd4f02c49673bc3b03b7cef65ad869feeb14c3ab1b245340919564741
MD5 90142ae8040a5d42d1c3016212ab0555
BLAKE2b-256 0ab10bd4481f8fa9964b07a7073502b5c1d993729a18a92599b187e165568bb6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page