Skip to content

Commit cddc1f5

Browse files
committed
Rename custom loggers to _logger
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent d0dcc8d commit cddc1f5

File tree

16 files changed

+47
-47
lines changed

16 files changed

+47
-47
lines changed

src/frequenz/sdk/actor/_config_managing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from ..actor._decorator import actor
1515
from ..config import Config
1616

17-
logger = logging.getLogger(__name__)
17+
_logger = logging.getLogger(__name__)
1818

1919

2020
@actor
@@ -80,10 +80,10 @@ async def run(self) -> None:
8080

8181
async for path in self._file_watcher:
8282
if str(path) == self._conf_file:
83-
logger.info(
83+
_logger.info(
8484
"Update configs, because file %s was modified.",
8585
self._conf_file,
8686
)
8787
await self.send_config()
8888

89-
logger.debug("ConfigManager stopped.")
89+
_logger.debug("ConfigManager stopped.")

src/frequenz/sdk/actor/_decorator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from frequenz.sdk._internal.asyncio import cancel_and_await
1818

19-
logger = logging.getLogger(__name__)
19+
_logger = logging.getLogger(__name__)
2020

2121
OT = TypeVar("OT")
2222

@@ -201,25 +201,25 @@ async def _start_actor(self) -> None:
201201
Raises:
202202
asyncio.CancelledError: when the actor's task gets cancelled.
203203
"""
204-
logger.debug("Starting actor: %s", cls.__name__)
204+
_logger.debug("Starting actor: %s", cls.__name__)
205205
number_of_restarts = 0
206206
while (
207207
self.restart_limit is None or number_of_restarts <= self.restart_limit
208208
):
209209
if number_of_restarts > 0:
210-
logger.info("Restarting actor: %s", cls.__name__)
210+
_logger.info("Restarting actor: %s", cls.__name__)
211211

212212
try:
213213
await super().run()
214214
except asyncio.CancelledError:
215-
logger.debug("Cancelling actor: %s", cls.__name__)
215+
_logger.debug("Cancelling actor: %s", cls.__name__)
216216
raise
217217
except Exception: # pylint: disable=broad-except
218-
logger.exception("Actor (%s) crashed", cls.__name__)
218+
_logger.exception("Actor (%s) crashed", cls.__name__)
219219
finally:
220220
number_of_restarts += 1
221221

222-
logger.info("Shutting down actor: %s", cls.__name__)
222+
_logger.info("Shutting down actor: %s", cls.__name__)
223223

224224
async def _stop(self) -> None:
225225
"""Stop an running actor."""

src/frequenz/sdk/actor/_resampling.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from ._data_sourcing import ComponentMetricRequest
1919
from ._decorator import actor
2020

21-
logger = logging.getLogger(__name__)
21+
_logger = logging.getLogger(__name__)
2222

2323

2424
@actor
@@ -139,12 +139,12 @@ async def run(self) -> None:
139139
if not isinstance(error, ResamplingError):
140140
raise error
141141
for source, source_error in error.exceptions.items():
142-
logger.error(
142+
_logger.error(
143143
"Error resampling source %s, removing source...", source
144144
)
145145
removed = self._resampler.remove_timeseries(source)
146146
if not removed:
147-
logger.warning(
147+
_logger.warning(
148148
"Got an exception from an unknown source: "
149149
"source=%r, exception=%r",
150150
source,

src/frequenz/sdk/config/_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from pydantic import ValidationError, parse_raw_as
1010

11-
log = logging.getLogger(__name__)
11+
_logger = logging.getLogger(__name__)
1212

1313
T = TypeVar("T")
1414

src/frequenz/sdk/microgrid/_data_pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from . import connection_manager
2121
from .component import ComponentCategory
2222

23-
logger = logging.getLogger(__name__)
23+
_logger = logging.getLogger(__name__)
2424

2525
# A number of imports had to be done inside functions where they are used, to break
2626
# import cycles.
@@ -207,7 +207,7 @@ def _start_power_distributing_actor(self) -> None:
207207
if not component_graph.components(
208208
component_category={ComponentCategory.BATTERY}
209209
):
210-
logger.warning(
210+
_logger.warning(
211211
"No batteries found in the component graph. "
212212
"The power distributing actor will not be started."
213213
)

src/frequenz/sdk/microgrid/_graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from .client import Connection, MicrogridApiClient
3333
from .component import Component, ComponentCategory
3434

35-
logger = logging.getLogger(__name__)
35+
_logger = logging.getLogger(__name__)
3636

3737

3838
class InvalidGraphError(Exception):
@@ -309,7 +309,7 @@ def refresh_from(
309309
try:
310310
_provisional.validate()
311311
except InvalidGraphError as err:
312-
logger.warning("Attempting to fix invalid component data: %s", err)
312+
_logger.warning("Attempting to fix invalid component data: %s", err)
313313
correct_errors(_provisional)
314314

315315
try:

src/frequenz/sdk/microgrid/client/_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
EVChargerData,
5656
)
5757

58-
logger = logging.getLogger(__name__)
58+
_logger = logging.getLogger(__name__)
5959

6060

6161
class MicrogridApiClient(ABC):
@@ -341,7 +341,7 @@ async def _component_data_task(
341341
"""
342342
retry_spec: RetryStrategy = self._retry_spec.copy()
343343
while True:
344-
logger.debug(
344+
_logger.debug(
345345
"Making call to `GetComponentData`, for component_id=%d", component_id
346346
)
347347
try:
@@ -354,15 +354,15 @@ async def _component_data_task(
354354
await sender.send(transform(msg))
355355
except grpc.aio.AioRpcError as err:
356356
api_details = f"Microgrid API: {self.target}."
357-
logger.exception(
357+
_logger.exception(
358358
"`GetComponentData`, for component_id=%d: exception: %s api: %s",
359359
component_id,
360360
err,
361361
api_details,
362362
)
363363

364364
if interval := retry_spec.next_interval():
365-
logger.warning(
365+
_logger.warning(
366366
"`GetComponentData`, for component_id=%d: connection ended, "
367367
"retrying %s in %0.3f seconds.",
368368
component_id,
@@ -371,7 +371,7 @@ async def _component_data_task(
371371
)
372372
await asyncio.sleep(interval)
373373
else:
374-
logger.warning(
374+
_logger.warning(
375375
"`GetComponentData`, for component_id=%d: connection ended, "
376376
"retry limit exceeded %s.",
377377
component_id,
@@ -658,7 +658,7 @@ async def set_bounds(
658658
),
659659
)
660660
except grpc.aio.AioRpcError as err:
661-
logger.error(
661+
_logger.error(
662662
"set_bounds write failed: %s, for message: %s, api: %s. Err: %s",
663663
err,
664664
next,

src/frequenz/sdk/timeseries/_formula_engine/_formula_engine.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
)
4141
from ._tokenizer import TokenType
4242

43-
logger = logging.Logger(__name__)
43+
_logger = logging.Logger(__name__)
4444

4545
_operator_precedence = {
4646
"(": 0,
@@ -301,10 +301,10 @@ async def _run(self) -> None:
301301
try:
302302
msg = await evaluator.apply()
303303
except asyncio.CancelledError:
304-
logger.exception("FormulaEngine task cancelled: %s", self._name)
304+
_logger.exception("FormulaEngine task cancelled: %s", self._name)
305305
raise
306306
except Exception as err: # pylint: disable=broad-except
307-
logger.warning(
307+
_logger.warning(
308308
"Formula application failed: %s. Error: %s", self._name, err
309309
)
310310
else:
@@ -374,7 +374,7 @@ async def _run(self) -> None:
374374
phase_3.value,
375375
)
376376
except asyncio.CancelledError:
377-
logger.exception("FormulaEngine task cancelled: %s", self._name)
377+
_logger.exception("FormulaEngine task cancelled: %s", self._name)
378378
break
379379
else:
380380
await sender.send(msg)

src/frequenz/sdk/timeseries/_formula_engine/_formula_generators/_battery_power_formula.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
FormulaGenerator,
1515
)
1616

17-
logger = logging.getLogger(__name__)
17+
_logger = logging.getLogger(__name__)
1818

1919

2020
class BatteryPowerFormula(FormulaGenerator):
@@ -43,7 +43,7 @@ def generate(
4343
builder = self._get_builder("battery-power", ComponentMetricId.ACTIVE_POWER)
4444
component_ids = self._config.component_ids
4545
if not component_ids:
46-
logger.warning(
46+
_logger.warning(
4747
"No Battery component IDs specified. "
4848
"Subscribing to the resampling actor with a non-existing "
4949
"component id, so that `0` values are sent from the formula."

src/frequenz/sdk/timeseries/_formula_engine/_formula_generators/_ev_charger_current_formula.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .._formula_engine import FormulaEngine, FormulaEngine3Phase
1313
from ._formula_generator import NON_EXISTING_COMPONENT_ID, FormulaGenerator
1414

15-
logger = logging.getLogger(__name__)
15+
_logger = logging.getLogger(__name__)
1616

1717

1818
class EVChargerCurrentFormula(FormulaGenerator):
@@ -27,7 +27,7 @@ def generate(self) -> FormulaEngine3Phase:
2727
component_ids = self._config.component_ids
2828

2929
if not component_ids:
30-
logger.warning(
30+
_logger.warning(
3131
"No EV Charger component IDs specified. "
3232
"Subscribing to the resampling actor with a non-existing "
3333
"component id, so that `0` values are sent from the formula."

0 commit comments

Comments
 (0)