Registry / observability / structlog-pretty

structlog-pretty

JSON →
library0.4.3pypypi✓ verified 84d ago

A collection of structlog processors to produce prettier log output, including syntax highlighting, numeric rounding, and key-value formatting. Current version 0.4.3, maintained but low release cadence.

pip install structlog-pretty
INSTALL
IMPORT
SIG · STRUCTLOG-PRETTY
S
structlog-pretty
observabilitypythonv0.4.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NumericRounder
from structlog_pretty.processors import NumericRounder
from structlog_pretty import NumericRounder
Top-level import fails; processors are in submodule.
SyntaxHighlighter
from structlog_pretty.processors import SyntaxHighlighter
from structlog_pretty import SyntaxHighlighter
Importing from top-level returns AttributeError.
KeyValueFormatter
from structlog_pretty.processors import KeyValueFormatter

Basic configuration with NumericRounder and KeyValueFormatter.

import structlog from structlog_pretty.processors import NumericRounder, KeyValueFormatter structlog.configure( processors=[ structlog.stdlib.add_log_level, structlog.processors.TimeStamper(fmt="iso"), NumericRounder(), KeyValueFormatter(), structlog.dev.ConsoleRenderer() ], context_class=dict, wrapper_class=structlog.stdlib.BoundLogger, cache_logger_on_first_use=True, ) log = structlog.get_logger() log.info("Logging with style", count=1234.5678, user="alice")
Debug
Known issues
breakingNumericRounder may convert boolean values to floats (0.0/1.0) unless you upgrade to v0.1.1 or later. Always use >=0.1.1.
fix
Upgrade: pip install structlog-pretty>=0.1.1
affects: <0.1.1
gotchaSyntaxHighlighter requires Pygments to be installed; otherwise it silently falls back to plain text. No error is raised.
fix
Install Pygments: pip install pygments
affects: all
gotchaTrailing whitespace in log messages is preserved, which can cause unexpected line breaks if not intended.
fix
Strip trailing whitespace manually if needed.
affects: >=0.4.3
Errors
Common errors & fixes
AttributeError: module 'structlog_pretty' has no attribute 'NumericRounder'
Importing from wrong module – should be structlog_pretty.processors.
fix
Use: from structlog_pretty.processors import NumericRounder
ValueError: cannot convert float NaN to integer
NumericRounder encountered NaN value; older versions had this bug if decimal places set incorrectly.
fix
Ensure value is not NaN or upgrade to latest version.
Upgrade
Version history
0.4.3latest on PyPI · released Jul 15, 2024
Audit
Dependencies
structlogrequiredRequired to use structlog processors.
pygmentsoptionalOptional dependency for SyntaxHighlighter processor.
Agent activity
25 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
structlog-pretty — pip install structlog-pretty · libregistry