diff --git a/piker/service/__init__.py b/piker/service/__init__.py index 3b9767cd..a885bc39 100644 --- a/piker/service/__init__.py +++ b/piker/service/__init__.py @@ -20,6 +20,7 @@ Actor-runtime service orchestration machinery. """ from __future__ import annotations +from ._util import log from ._mngr import Services from ._registry import ( # noqa _tractor_kwargs, diff --git a/piker/service/_actor_runtime.py b/piker/service/_actor_runtime.py index b92ad221..db727e2e 100644 --- a/piker/service/_actor_runtime.py +++ b/piker/service/_actor_runtime.py @@ -34,8 +34,8 @@ from contextlib import ( import tractor import trio -from ..log import ( - get_logger, +from ._util import ( + log, # sub-sys logger get_console_log, ) from ._mngr import ( @@ -47,8 +47,6 @@ from ._registry import ( # noqa open_registry, ) -log = get_logger(__name__) - def get_tractor_runtime_kwargs() -> dict[str, Any]: ''' diff --git a/piker/service/_ahab.py b/piker/service/_ahab.py index 7c3133e1..0629aeda 100644 --- a/piker/service/_ahab.py +++ b/piker/service/_ahab.py @@ -48,14 +48,12 @@ from requests.exceptions import ( ReadTimeout, ) -from ..log import ( - get_logger, +from ._util import ( + log, # sub-sys logger get_console_log, ) from .. import config -log = get_logger(__name__) - class DockerNotStarted(Exception): 'Prolly you dint start da daemon bruh' diff --git a/piker/service/_daemon.py b/piker/service/_daemon.py index 45d6cb81..e2581081 100644 --- a/piker/service/_daemon.py +++ b/piker/service/_daemon.py @@ -30,8 +30,8 @@ from contextlib import ( import tractor -from ..log import ( - get_logger, +from ._util import ( + log, # sub-sys logger get_console_log, ) from ..brokers import get_brokermod @@ -41,8 +41,6 @@ from ._mngr import ( from ._actor_runtime import maybe_open_pikerd from ._registry import find_service -log = get_logger(__name__) - # `brokerd` enabled modules # NOTE: keeping this list as small as possible is part of our caps-sec # model and should be treated with utmost care! diff --git a/piker/service/_mngr.py b/piker/service/_mngr.py index 04f396af..80a84487 100644 --- a/piker/service/_mngr.py +++ b/piker/service/_mngr.py @@ -28,12 +28,10 @@ import trio from trio_typing import TaskStatus import tractor -from ..log import ( - get_logger, +from ._util import ( + log, # sub-sys logger ) -log = get_logger(__name__) - # TODO: factor this into a ``tractor.highlevel`` extension # pack for the library. diff --git a/piker/service/_registry.py b/piker/service/_registry.py index f487e2a4..7ae11937 100644 --- a/piker/service/_registry.py +++ b/piker/service/_registry.py @@ -28,13 +28,10 @@ from typing import ( import tractor - -from ..log import ( - get_logger, +from ._util import ( + log, # sub-sys logger ) -log = get_logger(__name__) - _default_registry_host: str = '127.0.0.1' _default_registry_port: int = 6116 _default_reg_addr: tuple[str, int] = ( diff --git a/piker/service/_util.py b/piker/service/_util.py new file mode 100644 index 00000000..bdf23dab --- /dev/null +++ b/piker/service/_util.py @@ -0,0 +1,33 @@ +# piker: trading gear for hackers +# Copyright (C) Tyler Goodlet (in stewardship for pikers) + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +""" +Sub-sys module commons. + +""" +from functools import partial + +from ..log import ( + get_logger, + get_console_log, +) +subsys: str = 'piker.service' + +log = get_logger(subsys) + +get_console_log = partial( + get_console_log, + name=subsys, +) diff --git a/piker/service/elastic.py b/piker/service/elastic.py index 31221d57..71097dcb 100644 --- a/piker/service/elastic.py +++ b/piker/service/elastic.py @@ -20,21 +20,17 @@ from typing import ( TYPE_CHECKING, ) +import asks if TYPE_CHECKING: import docker from ._ahab import DockerContainer -from piker.log import ( - get_logger, - get_console_log +from . import log # sub-sys logger +from ._util import ( + get_console_log, ) -import asks - - -log = get_logger(__name__) - # container level config _config = { @@ -92,7 +88,7 @@ def start_elasticsearch( 'http://localhost:19200/_cat/health', params={'format': 'json'} )).json() - kog.info( + log.info( 'ElasticSearch cntr health:\n' f'{health}' ) diff --git a/piker/service/marketstore.py b/piker/service/marketstore.py index 5c4f90db..8d99b7cd 100644 --- a/piker/service/marketstore.py +++ b/piker/service/marketstore.py @@ -54,14 +54,14 @@ if TYPE_CHECKING: import docker from ._ahab import DockerContainer +from ._util import ( + log, # sub-sys logger + get_console_log, +) from ..data.feed import maybe_open_feed -from ..log import get_logger, get_console_log from .._profile import Profiler -log = get_logger(__name__) - - # ahabd-supervisor and container level config _config = { 'grpc_listen_port': 5995, @@ -703,7 +703,7 @@ async def open_tsdb_client( # profiler('Finished db arrays diffs') - syms = await storage.client.list_symbols() + _ = await storage.client.list_symbols() # log.info(f'Existing tsdb symbol set:\n{pformat(syms)}') # profiler(f'listed symbols {syms}') yield storage