Skip to content

Commit

Permalink
optimize logging module import
Browse files Browse the repository at this point in the history
  • Loading branch information
krahabb committed Jan 19, 2023
1 parent 49192ad commit e063bff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion custom_components/meross_lan/cover.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
from time import time
from datetime import datetime
from logging import DEBUG, INFO, WARNING
from logging import DEBUG, WARNING

from homeassistant.components.cover import (
DOMAIN as PLATFORM_COVER,
Expand Down
4 changes: 2 additions & 2 deletions custom_components/meross_lan/helpers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""
Helpers!
"""
import logging
from logging import getLogger
from functools import partial
from time import time
from homeassistant.util.dt import utcnow

from .merossclient import const as mc

LOGGER = logging.getLogger(__name__[:-8]) #get base custom_component name for logging
LOGGER = getLogger(__name__[:-8]) #get base custom_component name for logging
_TRAP_DICT = dict()

def LOGGER_trap(level, timeout, msg, *args):
Expand Down
4 changes: 2 additions & 2 deletions custom_components/meross_lan/meross_device_hub.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations
import logging

from logging import WARNING
from typing import Callable, Dict

from homeassistant.const import (
Expand Down Expand Up @@ -219,7 +219,7 @@ def _parse_hub(self, p_hub: dict) -> None:
self.needsave = True
for p_id in subdevices_actual:
subdevice = self.subdevices.get(p_id)
self.log(logging.WARNING, 0, "removing subdevice %s(%s) - configuration will be reloaded in 15 sec", subdevice.type, p_id)
self.log(WARNING, 0, "removing subdevice %s(%s) - configuration will be reloaded in 15 sec", subdevice.type, p_id)
# before reloading we have to be sure configentry data were persisted
# so we'll wait a bit..
# also, we're not registering an unsub and we're not checking
Expand Down
7 changes: 4 additions & 3 deletions custom_components/meross_lan/sensor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations
import logging

from logging import DEBUG
from time import localtime
from datetime import datetime, timedelta, timezone

Expand Down Expand Up @@ -212,7 +213,7 @@ def _handle_Appliance_Control_ConsumptionX(self, header: dict, payload: dict):
)
timestamp_lastreset = dt.timestamp() - self.device_timedelta
self.log(
logging.DEBUG, 0,
DEBUG, 0,
"MerossDevice(%s) Energy: device midnight = %d",
self.device_id, timestamp_lastreset
)
Expand All @@ -239,7 +240,7 @@ def get_timestamp(day):
timestamp_lastreset + self.device_timedelta + .5
)
self.log(
logging.DEBUG, 0,
DEBUG, 0,
"MerossDevice(%s) Energy: update last_reset to %s",
self.device_id, self._sensor_energy._attr_last_reset.isoformat()
)
Expand Down

0 comments on commit e063bff

Please sign in to comment.