From b4381c50059c6c5d303a30ffad3b747579c99332 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Fri, 20 Nov 2020 14:47:48 -0700 Subject: [PATCH] Move Notion logger to a package logger (#43450) --- homeassistant/components/notion/__init__.py | 11 ++++------- homeassistant/components/notion/const.py | 3 +++ homeassistant/components/notion/sensor.py | 7 ++----- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/notion/__init__.py b/homeassistant/components/notion/__init__.py index 296eb34934b..be4a47c6d85 100644 --- a/homeassistant/components/notion/__init__.py +++ b/homeassistant/components/notion/__init__.py @@ -1,7 +1,6 @@ """Support for Notion.""" import asyncio from datetime import timedelta -import logging from aionotion import async_get_client from aionotion.errors import InvalidCredentialsError, NotionError @@ -21,9 +20,7 @@ from homeassistant.helpers.update_coordinator import ( UpdateFailed, ) -from .const import DATA_COORDINATOR, DOMAIN - -_LOGGER = logging.getLogger(__name__) +from .const import DATA_COORDINATOR, DOMAIN, LOGGER PLATFORMS = ["binary_sensor", "sensor"] @@ -56,10 +53,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: entry.data[CONF_USERNAME], entry.data[CONF_PASSWORD], session ) except InvalidCredentialsError: - _LOGGER.error("Invalid username and/or password") + LOGGER.error("Invalid username and/or password") return False except NotionError as err: - _LOGGER.error("Config entry failed: %s", err) + LOGGER.error("Config entry failed: %s", err) raise ConfigEntryNotReady from err async def async_update(): @@ -94,7 +91,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: entry.entry_id ] = DataUpdateCoordinator( hass, - _LOGGER, + LOGGER, name=entry.data[CONF_USERNAME], update_interval=DEFAULT_SCAN_INTERVAL, update_method=async_update, diff --git a/homeassistant/components/notion/const.py b/homeassistant/components/notion/const.py index 6a6da180374..5541cfedc70 100644 --- a/homeassistant/components/notion/const.py +++ b/homeassistant/components/notion/const.py @@ -1,5 +1,8 @@ """Define constants for the Notion integration.""" +import logging + DOMAIN = "notion" +LOGGER = logging.getLogger(__package__) DATA_COORDINATOR = "coordinator" diff --git a/homeassistant/components/notion/sensor.py b/homeassistant/components/notion/sensor.py index 091dcd324dc..99af00c3b1a 100644 --- a/homeassistant/components/notion/sensor.py +++ b/homeassistant/components/notion/sensor.py @@ -1,5 +1,4 @@ """Support for Notion sensors.""" -import logging from typing import Callable from homeassistant.config_entries import ConfigEntry @@ -8,9 +7,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from . import NotionEntity -from .const import DATA_COORDINATOR, DOMAIN, SENSOR_TEMPERATURE - -_LOGGER = logging.getLogger(__name__) +from .const import DATA_COORDINATOR, DOMAIN, LOGGER, SENSOR_TEMPERATURE SENSOR_TYPES = {SENSOR_TEMPERATURE: ("Temperature", "temperature", TEMP_CELSIUS)} @@ -84,7 +81,7 @@ class NotionSensor(NotionEntity): if task["task_type"] == SENSOR_TEMPERATURE: self._state = round(float(task["status"]["value"]), 1) else: - _LOGGER.error( + LOGGER.error( "Unknown task type: %s: %s", self.coordinator.data["sensors"][self._sensor_id], task["task_type"],