Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename getLogger to get_hacs_logger #2399

Merged
merged 1 commit into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions action/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from custom_components.hacs.base import HacsBase
from custom_components.hacs.const import HACS_ACTION_GITHUB_API_HEADERS
from custom_components.hacs.exceptions import HacsException
from custom_components.hacs.utils.logger import getLogger
from custom_components.hacs.utils.logger import get_hacs_logger
from custom_components.hacs.validate.manager import ValidationManager

TOKEN = os.getenv("INPUT_GITHUB_TOKEN")
Expand All @@ -34,7 +34,7 @@
"theme",
]

logger = getLogger()
logger = get_hacs_logger()


def error(error: str):
Expand Down
4 changes: 2 additions & 2 deletions custom_components/hacs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
)
from .repositories import RERPOSITORY_CLASSES
from .utils.decode import decode_content
from .utils.logger import getLogger
from .utils.logger import get_hacs_logger
from .utils.queue_manager import QueueManager
from .utils.store import async_load_from_store, async_save_to_store

Expand Down Expand Up @@ -330,7 +330,7 @@ class HacsBase:
githubapi: GitHubAPI | None = None
hass: HomeAssistant | None = None
integration: Integration | None = None
log: logging.Logger = getLogger()
log: logging.Logger = get_hacs_logger()
queue: QueueManager | None = None
recuring_tasks = []
repositories: HacsRepositories = HacsRepositories()
Expand Down
4 changes: 2 additions & 2 deletions custom_components/hacs/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .const import CLIENT_ID, DOMAIN, MINIMUM_HA_VERSION
from .enums import ConfigurationType
from .utils.configuration_schema import RELEASE_LIMIT, hacs_config_option_schema
from .utils.logger import getLogger
from .utils.logger import get_hacs_logger


class HacsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
Expand All @@ -28,7 +28,7 @@ def __init__(self):
self._errors = {}
self.device = None
self.activation = None
self.log = getLogger()
self.log = get_hacs_logger()
self._progress_task = None
self._login_device = None

Expand Down
4 changes: 2 additions & 2 deletions custom_components/hacs/repositories/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from ..utils.backup import Backup, BackupNetDaemon
from ..utils.decode import decode_content
from ..utils.download import dowload_repository_content, gather_files_to_download
from ..utils.logger import getLogger
from ..utils.logger import get_hacs_logger
from ..utils.path import is_safe
from ..utils.queue_manager import QueueManager
from ..utils.store import async_remove_store
Expand Down Expand Up @@ -322,7 +322,7 @@ def __init__(self, hacs: HacsBase) -> None:
self.tree = []
self.treefiles = []
self.ref = None
self.logger = getLogger()
self.logger = get_hacs_logger()

def __str__(self) -> str:
"""Return a string representation of the repository."""
Expand Down
4 changes: 2 additions & 2 deletions custom_components/hacs/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ..base import HacsBase
from ..enums import HacsGitHubRepo
from ..repositories.base import HacsManifest, HacsRepository
from .logger import getLogger
from .logger import get_hacs_logger
from .store import (
async_load_from_store,
async_save_to_store,
Expand All @@ -33,7 +33,7 @@ class HacsData:

def __init__(self, hacs: HacsBase):
"""Initialize."""
self.logger = getLogger()
self.logger = get_hacs_logger()
self.hacs = hacs
self.content = {}

Expand Down
3 changes: 1 addition & 2 deletions custom_components/hacs/utils/logger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Custom logger for HACS."""
# pylint: disable=invalid-name
import logging
import os

Expand All @@ -14,6 +13,6 @@
)


def getLogger(_name: str = None) -> logging.Logger:
def get_hacs_logger() -> logging.Logger:
"""Return a Logger instance."""
return _HACSLogger
4 changes: 2 additions & 2 deletions custom_components/hacs/utils/queue_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import time

from ..exceptions import HacsExecutionStillInProgress
from .logger import getLogger
from .logger import get_hacs_logger

_LOGGER = getLogger()
_LOGGER = get_hacs_logger()


class QueueManager:
Expand Down
4 changes: 2 additions & 2 deletions custom_components/hacs/utils/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

from ..const import VERSION_STORAGE
from ..exceptions import HacsException
from .logger import getLogger
from .logger import get_hacs_logger

_LOGGER = getLogger()
_LOGGER = get_hacs_logger()


class HACSStore(Store):
Expand Down
6 changes: 3 additions & 3 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
from homeassistant.util.unit_system import METRIC_SYSTEM

from custom_components.hacs.repositories.base import HacsRepository
from custom_components.hacs.utils.logger import getLogger
from custom_components.hacs.utils.logger import get_hacs_logger
from custom_components.hacs.utils.version import version_to_download

from tests.async_mock import AsyncMock, Mock, patch

_LOGGER = getLogger(__name__)
_LOGGER = get_hacs_logger()
TOKEN = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
INSTANCES = []

Expand All @@ -40,7 +40,7 @@ def dummy_repository_base(hacs, repository=None):
repository.hacs = hacs
repository.hacs.hass = hacs.hass
repository.hacs.core.config_path = hacs.hass.config.path()
repository.logger = getLogger("test.test")
repository.logger = get_hacs_logger()
repository.data.full_name = "test/test"
repository.data.full_name_lower = "test/test"
repository.data.domain = "test"
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
)
from custom_components.hacs.repositories.base import HacsRepository
from custom_components.hacs.tasks.manager import HacsTaskManager
from custom_components.hacs.utils.logger import get_hacs_logger
from custom_components.hacs.utils.queue_manager import QueueManager
from custom_components.hacs.utils.version import version_to_download
from custom_components.hacs.validate.manager import ValidationManager
Expand Down Expand Up @@ -136,7 +137,7 @@ def repository(hacs):
repository_obj.hacs = hacs
repository_obj.hass = hacs.hass
repository_obj.hacs.core.config_path = hacs.hass.config.path()
repository_obj.logger = logging.getLogger("test")
repository_obj.logger = get_hacs_logger()
repository_obj.data.full_name = "test/test"
repository_obj.data.full_name_lower = "test/test"
repository_obj.data.domain = "test"
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/functions/test_logger.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os

from custom_components.hacs.utils.logger import getLogger
from custom_components.hacs.utils.logger import get_hacs_logger


def test_logger():
os.environ["GITHUB_ACTION"] = "value"
getLogger()
get_hacs_logger()
del os.environ["GITHUB_ACTION"]