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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: structlog_pretty-0.4.0.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.0.tar.gz
Algorithm Hash digest
SHA256 d34c0b062c11f4ff44f38a9ba5f2de10a78bb534c10b155d001d009484d002e4
MD5 d4b8b2d31d021a155b941796a483eaa1
BLAKE2b-256 1e945afcdf08dd218d2aa66e5d46024edacb04dad76d2615881067734238946e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for structlog_pretty-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e70aceed456311279aa21dfa245f17649de4ea56978df1628a4f5379496e665c
MD5 714a57df70cd62915022ee134201e409
BLAKE2b-256 c5190e0322db7a2cbcc13c97f962bcf7b5c9e3d16782db91b82bde417769b4e8

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