This release is a pre-release and may not be stable for production use.
structlog-configfile
Helpers to configure structlog together with standard-library logging from a small configuration module.
Installation
pip install structlog-configfile
Quick start
Replace the standard structlog logger factory with the package helper:
import structlog_configfile
logger = structlog_configfile.get_logger()
logger.info("hello", user="alice")
This loads the built-in defaults and configures both structlog and stdlib logging.
Using a custom configuration module
You can point the helper at your own Python configuration module:
import structlog_configfile
logger = structlog_configfile.get_logger(config_file="path/to/my_config.py"[, struct_log_logger_args])
You can also set the environment variable STRUCTLOG_CONFIG_FILE to avoid passing the path explicitly.
Example configuration module:
from pathlib import Path
import structlog
logging_config_file = Path(__file__).parent.joinpath("logging.yaml")
pre_process_processors = [
structlog.processors.TimeStamper(fmt="iso"),
]
structlog_processors = []
logging_processors = []
post_process_processors = []
renderer = structlog.processors.JSONRenderer()
handleStdlib = True
Supported configuration knobs
The configuration module can define the following values:
logging_config_file: path to the stdlib logging configuration file (https://docs.python.org/3/library/logging.config.html)pre_process_processors: processors applied before other processorsstructlog_processors: processors used for structlog logslogging_processors: processors used for stdlib loggingpost_process_processors: processors applied after all othersrenderer: the final renderer used by the logging formatterstdlib_preprocessor: processors for stdlib log preparationstdlib_processor: processors for stdlib log handlingstdlib_postprocessor: processors applied after stdlib processingembeds_std_lib: enable or disable stdlib logging setup
Logging configuration file formats
The file referenced by logging_config_file can be a Jinja template or a YAML, JSON, or TOML file. The package will load it and use it for stdlib logging configuration.
Notes
The package exposes both get_logger() and getLoger() for compatibility.
Metadata
Release files for structlog-configfile 1.0.0rc2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| structlog_configfile-1.0.0rc2.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| structlog_configfile-1.0.0rc2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.0 kB
Release files / structlog_configfile-1.0.0rc2.tar.gz
| Download URL | structlog_configfile-1.0.0rc2.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac9058a07910950b98b6c66a41c8bdb2ffbc68a89426e870b18e3a28980595f6
|
|
BLAKE2b-256 checksum How to use checksums |
3f61c555ff0c766508466940af001a5316ff72f05d78e81973657670c12b0f75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / structlog_configfile-1.0.0rc2-py3-none-any.whl
| Download URL | structlog_configfile-1.0.0rc2-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f67c229a9d08699ca3b637c937db14f8f8a594e2e3997509c6c6575a8e3d03db
|
|
BLAKE2b-256 checksum How to use checksums |
f1ad92b283f0adcc22d934159651df74706178373ba75cd7117366f112835a05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|