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.PathPrettifier(),
    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.4.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

structlog_pretty-0.4.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file structlog_pretty-0.4.1.tar.gz.

File metadata

  • Download URL: structlog_pretty-0.4.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.25.0

File hashes

Hashes for structlog_pretty-0.4.1.tar.gz
Algorithm Hash digest
SHA256 34b1bc827654fa9d9c61aa678c61be89b25699ce52670c5849b7f040e85aed29
MD5 487b02b23fb7efd78104fe243556f570
BLAKE2b-256 dab08fb4d9a318489468494c90044625692f80dee0c1b8735520984135d299ef

See more details on using hashes here.

File details

Details for the file structlog_pretty-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for structlog_pretty-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0410cc00d8f1cb50231e5016e505758775112737ae9403ffa924b302303965cc
MD5 06602bd9443d316d0879f16c969b3798
BLAKE2b-256 06e4aaafa23f0d75922dff00bdd6a7337614fee5b12417cea30ac3f0a513412a

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