Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/underyx/structlog-pretty
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.
https://github.com/underyx/structlog-pretty
logging python structured-logging
Last synced: 4 days ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/underyx/structlog-pretty
- Owner: underyx
- License: mit
- Created: 2016-11-18T12:29:56.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2024-07-15T19:39:07.000Z (6 months ago)
- Last Synced: 2025-01-07T01:31:20.724Z (11 days ago)
- Topics: logging, python, structured-logging
- Language: Python
- Homepage:
- Size: 40 KB
- Stars: 35
- Watchers: 4
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
structlog-pretty
================.. image:: https://circleci.com/gh/underyx/structlog-pretty.svg?style=shield
:target: https://circleci.com/gh/underyx/structlog-pretty
:alt: CI Status.. image:: https://codecov.io/gh/underyx/structlog-pretty/branch/master/graph/badge.svg
:target: https://codecov.io/gh/underyx/structlog-pretty
:alt: Code CoverageA 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
.. code-block:: python
import structlog
import structlog_prettystructlog.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
.. code-block:: python
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']),
# ...
],.. _structlog: https://github.com/hynek/structlog