@@ -117,38 +117,40 @@ def _read_config(self) -> abc.Mapping[str, Any] | None:
117117 config : dict [str , Any ] = {}
118118
119119 for config_path in self ._config_paths :
120- _logger .info ("%s: Reading configuration file %s..." , self , config_path )
120+ _logger .info (
121+ "[%s] Reading configuration file %r..." , self .name , str (config_path )
122+ )
121123 try :
122124 with config_path .open ("rb" ) as toml_file :
123125 data = tomllib .load (toml_file )
124126 _logger .info (
125- "%s: Configuration file %r read successfully." ,
126- self ,
127+ "[%s] Configuration file %r read successfully." ,
128+ self . name ,
127129 str (config_path ),
128130 )
129131 config = _recursive_update (config , data )
130132 except ValueError as err :
131- _logger .error ("%s: Can't read config file, err: %s" , self , err )
133+ _logger .error ("[%s] Can't read config file, err: %s" , self . name , err )
132134 error_count += 1
133135 except OSError as err :
134136 # It is ok for config file to don't exist.
135137 _logger .error (
136- "%s: Error reading config file %r (%s). Ignoring it." ,
137- self ,
138+ "[%s] Error reading config file %r (%s). Ignoring it." ,
139+ self . name ,
138140 str (config_path ),
139141 err ,
140142 )
141143 error_count += 1
142144
143145 if error_count == len (self ._config_paths ):
144146 _logger .error (
145- "%s: Can't read any of the config files, ignoring config update." , self
147+ "[%s] Can't read any of the config files, ignoring config update." , self
146148 )
147149 return None
148150
149151 _logger .info (
150- "%s: Read %s/%s configuration files successfully." ,
151- self ,
152+ "[%s] Read %s/%s configuration files successfully." ,
153+ self . name ,
152154 len (self ._config_paths ) - error_count ,
153155 len (self ._config_paths ),
154156 )
@@ -185,8 +187,8 @@ async def _run(self) -> None:
185187 async for event in file_watcher :
186188 if not event .path .exists ():
187189 _logger .error (
188- "%s: Received event %s, but the watched path %s doesn't exist." ,
189- self ,
190+ "[%s] Received event %s, but the watched path %s doesn't exist." ,
191+ self . name ,
190192 event ,
191193 event .path ,
192194 )
@@ -207,23 +209,23 @@ async def _run(self) -> None:
207209 match event .type :
208210 case EventType .CREATE :
209211 _logger .info (
210- "%s: The configuration file %s was created, sending new config..." ,
211- self ,
212+ "[%s] The configuration file %s was created, sending new config..." ,
213+ self . name ,
212214 event .path ,
213215 )
214216 await self .send_config ()
215217 case EventType .MODIFY :
216218 _logger .info (
217- "%s: The configuration file %s was modified, sending update..." ,
218- self ,
219+ "[%s] The configuration file %s was modified, sending update..." ,
220+ self . name ,
219221 event .path ,
220222 )
221223 await self .send_config ()
222224 case EventType .DELETE :
223225 _logger .error (
224- "%s: Unexpected DELETE event for path %s. Please report this "
226+ "[%s] Unexpected DELETE event for path %s. Please report this "
225227 "issue to Frequenz." ,
226- self ,
228+ self . name ,
227229 event .path ,
228230 )
229231 case _:
0 commit comments