Logging Configuration¶
Logging configuration utilities for dotenvmodel.
logging_config ¶
Logging configuration utilities for dotenvmodel.
configure_logging ¶
configure_logging(
level: str | int | None = None,
*,
format_string: str | None = None,
handler: Handler | None = None,
) -> None
Configure logging for dotenvmodel.
This is a convenience function to quickly enable dotenvmodel logging. For more control, configure the 'dotenvmodel' logger directly using the standard logging module.
When to use
- During development to debug config loading issues
- In production to log which .env files are loaded
- When troubleshooting missing or invalid config values
When NOT to use
- In production with DEBUG level (too verbose)
- If your app already configures the root logger comprehensively
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
str | int | None
|
Logging level. Can be a string ("DEBUG", "INFO", "WARNING", "ERROR")
or an int (logging.DEBUG, etc.). If None, reads from
|
None
|
format_string
|
str | None
|
Custom format string for log messages. If None, uses
|
None
|
handler
|
Handler | None
|
Custom logging handler. If None, uses |
None
|
Example
from dotenvmodel import configure_logging
# Enable INFO level logging
configure_logging("INFO")
# Or use DEBUG for more verbose output
configure_logging("DEBUG")
# Custom format
configure_logging("DEBUG", format_string="[%(levelname)s] %(message)s")
# Via environment variable (no code change needed)
# export DOTENVMODEL_LOG_LEVEL=DEBUG
See Also
disable_logging: Turn off all logging.
Source code in dotenvmodel/logging_config.py
disable_logging ¶
Disable all dotenvmodel logging.
When to use
- When you want to completely silence dotenvmodel log output
- After temporarily enabling logging for debugging
See Also
configure_logging: Enable/configure logging.