Skip to content

Commit 5123a97

Browse files
committed
Improve logging for configuration file reading
Signed-off-by: Leandro Lucarella <[email protected]>
1 parent f1f2861 commit 5123a97

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/frequenz/sdk/config/_managing_actor.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,26 @@ 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)
120121
try:
121122
with config_path.open("rb") as toml_file:
122123
data = tomllib.load(toml_file)
124+
_logger.info(
125+
"%s: Configuration file %r read successfully.",
126+
self,
127+
str(config_path),
128+
)
123129
config = _recursive_update(config, data)
124130
except ValueError as err:
125131
_logger.error("%s: Can't read config file, err: %s", self, err)
126132
error_count += 1
127133
except OSError as err:
128134
# It is ok for config file to don't exist.
129135
_logger.error(
130-
"%s: Error reading config file %s (%s). Ignoring it.",
136+
"%s: Error reading config file %r (%s). Ignoring it.",
131137
self,
138+
str(config_path),
132139
err,
133-
config_path,
134140
)
135141
error_count += 1
136142

@@ -140,6 +146,12 @@ def _read_config(self) -> abc.Mapping[str, Any] | None:
140146
)
141147
return None
142148

149+
_logger.info(
150+
"%s: Read %s/%s configuration files successfully.",
151+
self,
152+
len(self._config_paths) - error_count,
153+
len(self._config_paths),
154+
)
143155
return config
144156

145157
async def send_config(self) -> None:

0 commit comments

Comments
 (0)