Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

## Bug Fixes

<!-- Here goes notable bug fixes that are worth a special mention or explanation -->
* Fix bug with LoggingConfigUpdater not updating root logger level.
20 changes: 14 additions & 6 deletions src/frequenz/sdk/config/_logging_config_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,25 @@ def __init__(
config_recv: The receiver to listen for configuration changes.
log_format: Use the specified format string in logs.
log_datefmt: Use the specified date/time format in logs.

Note:
The `log_format` and `log_datefmt` parameters are used in a call to
`logging.basicConfig()`. If logging has already been configured elsewhere
in the application (through a previous `basicConfig()` call), then the format
settings specified here will be ignored.
"""
super().__init__()
self._config_recv = config_recv
self._format = log_format
self._datefmt = log_datefmt

# Setup default configuration.
# This ensures logging is configured even if actor fails to start or
# if the configuration cannot be loaded.
self._current_config: LoggingConfig = LoggingConfig()

logging.basicConfig(
format=log_format,
datefmt=log_datefmt,
)
self._update_logging(self._current_config)

async def _run(self) -> None:
Expand All @@ -176,11 +185,10 @@ def _update_logging(self, config: LoggingConfig) -> None:
logging.getLogger(logger_id).setLevel(logging.NOTSET)

self._current_config = config
logging.basicConfig(
format=self._format,
level=self._current_config.root_logger.level,
datefmt=self._datefmt,
_logger.debug(
"Setting root logger level to '%s'", self._current_config.root_logger.level
)
logging.getLogger().setLevel(self._current_config.root_logger.level)

# For each logger in the new config, set the log level
for logger_id, logger_config in self._current_config.loggers.items():
Expand Down
Loading