@@ -141,16 +141,25 @@ def __init__(
141
141
config_recv: The receiver to listen for configuration changes.
142
142
log_format: Use the specified format string in logs.
143
143
log_datefmt: Use the specified date/time format in logs.
144
+
145
+ Note:
146
+ The `log_format` and `log_datefmt` parameters are used in a call to
147
+ `logging.basicConfig()`. If logging has already been configured elsewhere
148
+ in the application (through a previous `basicConfig()` call), then the format
149
+ settings specified here will be ignored.
144
150
"""
145
151
super ().__init__ ()
146
152
self ._config_recv = config_recv
147
- self ._format = log_format
148
- self ._datefmt = log_datefmt
149
153
150
154
# Setup default configuration.
151
155
# This ensures logging is configured even if actor fails to start or
152
156
# if the configuration cannot be loaded.
153
157
self ._current_config : LoggingConfig = LoggingConfig ()
158
+
159
+ logging .basicConfig (
160
+ format = log_format ,
161
+ datefmt = log_datefmt ,
162
+ )
154
163
self ._update_logging (self ._current_config )
155
164
156
165
async def _run (self ) -> None :
@@ -176,11 +185,10 @@ def _update_logging(self, config: LoggingConfig) -> None:
176
185
logging .getLogger (logger_id ).setLevel (logging .NOTSET )
177
186
178
187
self ._current_config = config
179
- logging .basicConfig (
180
- format = self ._format ,
181
- level = self ._current_config .root_logger .level ,
182
- datefmt = self ._datefmt ,
188
+ _logger .debug (
189
+ "Setting root logger level to '%s'" , self ._current_config .root_logger .level
183
190
)
191
+ logging .getLogger ().setLevel (self ._current_config .root_logger .level )
184
192
185
193
# For each logger in the new config, set the log level
186
194
for logger_id , logger_config in self ._current_config .loggers .items ():
0 commit comments