Skip to content

Commit ffeafb9

Browse files
Use custom loggers for each module
Rather than using the global logging module. Signed-off-by: Daniel Zullo <[email protected]>
1 parent b49eb89 commit ffeafb9

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/frequenz/sdk/actor/_config_managing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _read_config(self) -> dict[str, Any]:
7474
with self._config_path.open("rb") as toml_file:
7575
return tomllib.load(toml_file)
7676
except ValueError as err:
77-
logging.error("%s: Can't read config file, err: %s", self, err)
77+
_logger.error("%s: Can't read config file, err: %s", self, err)
7878
raise
7979

8080
async def send_config(self) -> None:

src/frequenz/sdk/timeseries/_grid_frequency.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# Imported here to avoid a circular import.
2222
from ..actor import ComponentMetricRequest
2323

24+
_logger = logging.getLogger(__name__)
25+
2426

2527
def create_request(component_id: int) -> ComponentMetricRequest:
2628
"""Create a request for grid frequency.
@@ -87,15 +89,15 @@ def new_receiver(self) -> Receiver[Sample[Frequency]]:
8789
if not self._task:
8890
self._task = asyncio.create_task(self._send_request())
8991
else:
90-
logging.info("Grid frequency request already sent: %s", self._component)
92+
_logger.info("Grid frequency request already sent: %s", self._component)
9193

9294
return receiver
9395

9496
async def _send_request(self) -> None:
9597
"""Send the request for grid frequency."""
96-
logging.info("Sending request for grid frequency: %s", self._component)
98+
_logger.info("Sending request for grid frequency: %s", self._component)
9799
await self._request_sender.send(self._component_metric_request)
98-
logging.info("Sent request for grid frequency: %s", self._component)
100+
_logger.info("Sent request for grid frequency: %s", self._component)
99101

100102
@staticmethod
101103
def find_frequency_component() -> Component:

src/frequenz/sdk/timeseries/ev_charger_pool/_set_current_bounds.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ async def _run(self) -> None:
115115
continue
116116
latest_bound[bound.component_id] = bound
117117
min_voltage = min(meter.voltage_per_phase)
118-
logging.info("sending new bounds: %s", bound)
118+
_logger.info("sending new bounds: %s", bound)
119119
await api_client.set_bounds(
120120
bound.component_id,
121121
0,
@@ -124,7 +124,7 @@ async def _run(self) -> None:
124124
elif selected_from(selected, timer):
125125
for bound in latest_bound.values():
126126
min_voltage = min(meter.voltage_per_phase)
127-
logging.debug("resending bounds: %s", bound)
127+
_logger.debug("resending bounds: %s", bound)
128128
await api_client.set_bounds(
129129
bound.component_id,
130130
0,

src/frequenz/sdk/timeseries/grid.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from ..microgrid.component._component import ComponentCategory
1616
from ..microgrid.fuse import Fuse
1717

18+
_logger = logging.getLogger(__name__)
19+
1820

1921
@dataclass(frozen=True)
2022
class Grid:
@@ -49,7 +51,7 @@ def initialize(components: Iterable[Component]) -> None:
4951
grid_connections_count = len(grid_connections)
5052

5153
if grid_connections_count == 0:
52-
logging.info(
54+
_logger.info(
5355
"No grid connection found for this microgrid. This is normal for an islanded microgrid."
5456
)
5557
elif grid_connections_count > 1:

0 commit comments

Comments
 (0)