Introduction to a Handy Python Package - structlog
When starting with Python’s logging module, many of us have encountered confusion, as with the following code example:
import logging
log = logging.getLogger(__name__)
log.info('Hello')
We might expect this code to print the string Hello, but it doesn’t.
This is because the default log level for Python’s logging module is WARNING, so only messages at WARNING, ERROR, or CRITICAL levels are displayed.
To properly use the logging module, setting it up is necessary, which often means consulting the Python documentation. This isn’t a problem with Python per se, but rather a design philosophy difference.
So, is there a package more intuitive and easier to use than the built-in logging module?
The answer is “yes,” and that is the structlog package, which this article introduces.
Posted on Aug 30, 2023 in Python Module Recommendations , Python Programming - Beginner Level by Amo Chen ‐ 4 min read