Skip to main content
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.PathPrettifier(),
    structlog_pretty.SyntaxHighlighter({'request': 'json', 'response': 'json', 'soap_response': 'xml'}),
    structlog_pretty.MultilinePrinter(['request', 'response', 'soap_response']),
    # ...
],

Metadata

Release files for structlog-pretty 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for structlog-pretty 0.4.3
File Size Uploaded
structlog_pretty-0.4.3.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for structlog-pretty 0.4.3
File Interpreter ABI Platform
structlog_pretty-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 13.1 kB

Release files / structlog_pretty-0.4.3.tar.gz

Download URL structlog_pretty-0.4.3.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e5c6a8e98cdacd517a469dbedfe70de33eff5f2537343933024d6e2c0da8711d
BLAKE2b-256 checksum
How to use checksums
9e4cfaf8822fa7af8cfe3f7d93bba98db57e1e63be3c87378e7599668436602b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.25.0

Release files / structlog_pretty-0.4.3-py3-none-any.whl

Download URL structlog_pretty-0.4.3-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
352a2e0a1c59b95ef37da9da6caa7e3b25c34a8d7793fcc910c277eb7584d2bb
BLAKE2b-256 checksum
How to use checksums
2a57d6c3d2b337d3cc35359d072ce821d3991fee0d256ad2b1bd4b9e386cc099
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.25.0

Release history Release notifications | RSS feed

This release

0.4.3 This release

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

1 release file

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page