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")
Errors
Common errors & fixes
AttributeError: module 'structlog_pretty' has no attribute 'NumericRounder'
Importing from wrong module – should be structlog_pretty.processors.
fixUse: 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.
fixEnsure 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.