Logistro is an extremely light wrapper over Python's standard `logging` module, providing sensible defaults for logging configuration. It simplifies common logging setups and includes specialized functionality like `getPipeLogger()` for piping subprocess stderr to the main logger. The library is currently at version 2.0.1 and maintains an active development status, with recent releases focused on minor fixes and metadata updates.
pip install logistroVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize Logistro, use its custom logging levels (`debug2`), integrate with subprocesses using `getPipeLogger()`, and dynamically switch between human-readable and structured (JSON) output formats.
Call `logistro.set_structured()` or `logistro.set_human()` early in your application's lifecycle, ideally before `logistro.getLogger()` is first called for the root logger. If changing mid-execution, re-coerce the logger: `logistro.set_structured(); logistro.coerce_logger(logistro.getLogger())`.
Do not pass a `format` argument to `logistro.betterConfig()`. Instead, use `logistro.set_human()` (default) or `logistro.set_structured()` to control the output format globally.
Always ensure `os.close(pipe)` is called after the subprocess that uses the pipe has terminated and its output has been consumed or is no longer needed.
pip install logistro
logger = logistro.get_logger(__name__)
import subprocess
import logistro
logistro.basicConfig()
logger = logistro.get_logger(__name__)
# Ensure stderr is piped
process = subprocess.Popen(
['your_command_here'],
stderr=subprocess.PIPE # This is the crucial part
)
logistro.getPipeLogger(logger, process)
process.wait()import logistro
# Set the basic configuration level to DEBUG or lower to see debug messages
logistro.basicConfig(level=logistro.DEBUG)
logger = logistro.get_logger(__name__)
logger.debug("This debug message will now be shown.")
logger.info("This is an info message.")No dependency data recorded yet.