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

Uploaded Source

Built Distribution

structlog_pretty-0.2.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: structlog-pretty-0.2.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.1

File hashes

Hashes for structlog-pretty-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f232d6ec487fb0e64666bdffce507499374ca4b9007ee5d07b084466a21b1a15
MD5 8c00d3e9628ecc82ede4707a1e3dba0a
BLAKE2b-256 b932aacf25977396764429e8f8bed883caf3ff3d48ca4f06ca6cc9eff84266b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: structlog_pretty-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.1

File hashes

Hashes for structlog_pretty-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8252e459c7f74cffedc7ce8f6a20ca9173cd12b6da125f910e912ca5a7cae4e1
MD5 77020456bc18f11fdf2989a2bec01a3b
BLAKE2b-256 92645d2bb1185481bc80ccb15a3a7472fd0bc388fa69dd34508819e5bea9a42a

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