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

Uploaded Source

Built Distribution

structlog_pretty-0.1.1-py2.py3-none-any.whl (6.2 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for structlog-pretty-0.1.1.tar.gz
Algorithm Hash digest
SHA256 71911c4851ef457aeb8bb001bf7ae7103d845ee6e57c01d482c9132f72deebc9
MD5 a55854f98918bd9d1b8bdf42b6c98ce1
BLAKE2b-256 09c79527c67a6cde261a5682e6f03a7ccd897e3b4fb668ef31ca69d868dfd204

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for structlog_pretty-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 aded8e6d198a2dcc0c7c426f4689d4328f54a0d7d3aca0b056de856ee70d503a
MD5 ef40d1e1a8d7b16d5c0a7ff3c6317554
BLAKE2b-256 a2ff7c971cd8f13fe148c2c71e016423794d0c260d5771086a17ad23e7178f79

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