Skip to content

Commit 8cb3c06

Browse files
committed
@GitHK review: rename
1 parent ce18732 commit 8cb3c06

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

packages/pytest-simcore/src/pytest_simcore/logging.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66

77
import pytest
88
from pytest_mock import MockerFixture
9-
from servicelib.logging_utils import setup_async_loggers_lifespan
9+
from servicelib.logging_utils import async_loggers
1010

1111

1212
@pytest.fixture(autouse=True)
1313
def preserve_caplog_for_async_logging(mocker: MockerFixture) -> None:
14-
# Patch setup_async_loggers_lifespan to preserve caplog handlers,
14+
# Patch async_loggers to preserve caplog handlers,
1515
# and pytest logs in general as pytest captures logs in a special way
1616
# that is not compatible with the queue handler used in async logging.
17-
original_setup = setup_async_loggers_lifespan
17+
original_setup = async_loggers
1818

1919
@contextmanager
20-
def patched_setup_async_loggers_lifespan(**kwargs) -> Iterator[None]:
20+
def patched_async_loggers(**kwargs) -> Iterator[None]:
2121
# Find caplog's handler in root logger
2222
root_logger = logging.getLogger()
2323
caplog_handlers = [
@@ -32,11 +32,11 @@ def patched_setup_async_loggers_lifespan(**kwargs) -> Iterator[None]:
3232
yield
3333

3434
methods_to_patch = [
35-
"servicelib.logging_utils.setup_async_loggers_lifespan",
36-
"servicelib.fastapi.logging_lifespan.setup_async_loggers_lifespan",
37-
"tests.test_logging_utils.setup_async_loggers_lifespan",
35+
"servicelib.logging_utils.async_loggers",
36+
"servicelib.fastapi.logging_lifespan.async_loggers",
37+
"tests.test_logging_utils.async_loggers",
3838
]
3939
for method in methods_to_patch:
4040
with contextlib.suppress(AttributeError, ModuleNotFoundError):
4141
# Patch the method to use our patched version
42-
mocker.patch(method, patched_setup_async_loggers_lifespan)
42+
mocker.patch(method, patched_async_loggers)

packages/service-library/src/servicelib/fastapi/logging_lifespan.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
from ..logging_utils import (
99
LogLevelInt,
10+
async_loggers,
1011
log_context,
11-
setup_async_loggers_lifespan,
1212
)
1313
from ..logging_utils_filtering import LoggerName, MessageSubstring
1414
from .lifespan_utils import Lifespan
@@ -27,7 +27,7 @@ def logging_lifespan(
2727
"""Returns a FastAPI-compatible lifespan handler to set up async logging."""
2828
exit_stack = AsyncExitStack()
2929
exit_stack.enter_context(
30-
setup_async_loggers_lifespan(
30+
async_loggers(
3131
log_base_level=log_base_level,
3232
noisy_loggers=noisy_loggers,
3333
log_format_local_dev_enabled=log_format_local_dev_enabled,
@@ -62,7 +62,7 @@ def setup_logging_shutdown_event(
6262
"""
6363
exit_stack = AsyncExitStack()
6464
exit_stack.enter_context(
65-
setup_async_loggers_lifespan(
65+
async_loggers(
6666
log_base_level=log_base_level,
6767
noisy_loggers=noisy_loggers,
6868
log_format_local_dev_enabled=log_format_local_dev_enabled,

packages/service-library/src/servicelib/logging_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def setup_loggers(
258258

259259

260260
@contextmanager
261-
def setup_async_loggers_lifespan(
261+
def async_loggers(
262262
*,
263263
log_format_local_dev_enabled: bool,
264264
logger_filter_mapping: dict[LoggerName, list[MessageSubstring]],
@@ -270,7 +270,7 @@ def setup_async_loggers_lifespan(
270270
context manager for non-blocking logging infrastructure.
271271
272272
Usage:
273-
with setup_async_loggers_lifespan(log_format_local_dev_enabled=True, logger_filter_mapping={}, tracing_settings=None):
273+
with async_loggers(log_format_local_dev_enabled=True, logger_filter_mapping={}, tracing_settings=None):
274274
# Your async application code here
275275
logger.info("This is non-blocking!")
276276

packages/service-library/tests/test_logging_utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
LogExtra,
1414
LogLevelInt,
1515
LogMessageStr,
16+
async_loggers,
1617
guess_message_log_level,
1718
log_context,
1819
log_decorator,
1920
log_exceptions,
2021
set_parent_module_log_level,
21-
setup_async_loggers_lifespan,
2222
)
2323
from tenacity import (
2424
retry,
@@ -443,7 +443,7 @@ def test_setup_async_loggers_basic(
443443
caplog.clear()
444444
caplog.set_level(logging.INFO)
445445

446-
with setup_async_loggers_lifespan(
446+
with async_loggers(
447447
log_format_local_dev_enabled=log_format_local_dev_enabled,
448448
logger_filter_mapping={}, # No filters for this test
449449
tracing_settings=None, # No tracing for this test
@@ -467,7 +467,7 @@ def test_setup_async_loggers_with_filters(
467467
"test_filtered_logger": ["filtered_message"],
468468
}
469469

470-
with setup_async_loggers_lifespan(
470+
with async_loggers(
471471
log_format_local_dev_enabled=True,
472472
logger_filter_mapping=filter_mapping,
473473
tracing_settings=None, # No tracing for this test
@@ -504,7 +504,7 @@ def test_setup_async_loggers_with_tracing_settings(
504504

505505
# Note: We can't easily test actual tracing without setting up OpenTelemetry
506506
# But we can test that the function accepts the parameter
507-
with setup_async_loggers_lifespan(
507+
with async_loggers(
508508
log_format_local_dev_enabled=False,
509509
logger_filter_mapping={}, # No filters for this test
510510
tracing_settings=None,
@@ -526,7 +526,7 @@ def test_setup_async_loggers_context_manager_cleanup(
526526

527527
test_logger = logging.getLogger("test_cleanup_logger")
528528

529-
with setup_async_loggers_lifespan(
529+
with async_loggers(
530530
log_format_local_dev_enabled=True,
531531
logger_filter_mapping={},
532532
tracing_settings=None,
@@ -552,7 +552,7 @@ def _raise_test_exception():
552552
raise ValueError(exc_msg)
553553

554554
try:
555-
with setup_async_loggers_lifespan(
555+
with async_loggers(
556556
log_format_local_dev_enabled=True,
557557
logger_filter_mapping={},
558558
tracing_settings=None,

services/web/server/src/simcore_service_webserver/log.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from aiodebug import log_slow_callbacks # type: ignore[import-untyped]
99
from aiohttp import web
1010
from aiohttp.log import access_logger
11-
from servicelib.logging_utils import setup_async_loggers_lifespan
11+
from servicelib.logging_utils import async_loggers
1212
from simcore_service_webserver.application_settings import ApplicationSettings
1313

1414
_NOISY_LOGGERS: Final[tuple[str, ...]] = (
@@ -33,7 +33,7 @@
3333
def setup_logging(app_settings: ApplicationSettings) -> CleanupEvent:
3434
exit_stack = AsyncExitStack()
3535
exit_stack.enter_context(
36-
setup_async_loggers_lifespan(
36+
async_loggers(
3737
log_base_level=app_settings.log_level,
3838
noisy_loggers=_NOISY_LOGGERS,
3939
log_format_local_dev_enabled=app_settings.WEBSERVER_LOG_FORMAT_LOCAL_DEV_ENABLED,

0 commit comments

Comments
 (0)