Skip to content

Commit b346a81

Browse files
committed
Rename log filter processor function for clarity and update logger configuration to use the new function name.
1 parent ffa8be9 commit b346a81

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/app/core/logger.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def drop_color_message_key(_, __, event_dict: EventDict) -> EventDict:
2121
return event_dict
2222

2323

24-
def log_filter_processors(_, __, event_dict: EventDict) -> EventDict:
24+
def file_log_filter_processors(_, __, event_dict: EventDict) -> EventDict:
2525
"""Filter out the request ID, path, method, client host, and status code from the event dict if the
2626
corresponding setting is False."""
2727

@@ -102,7 +102,9 @@ def build_formatter(*, json_output: bool, pre_chain: list[Processor]) -> structl
102102
)
103103
file_handler.setLevel(settings.FILE_LOG_LEVEL)
104104
file_handler.setFormatter(
105-
build_formatter(json_output=settings.FILE_LOG_FORMAT_JSON, pre_chain=SHARED_PROCESSORS + [log_filter_processors])
105+
build_formatter(
106+
json_output=settings.FILE_LOG_FORMAT_JSON, pre_chain=SHARED_PROCESSORS + [file_log_filter_processors]
107+
)
106108
)
107109

108110
# Console handler configuration

src/app/core/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from ..api.dependencies import get_current_superuser
1616
from ..core.utils.rate_limit import rate_limiter
1717
from ..middleware.client_cache_middleware import ClientCacheMiddleware
18+
from ..middleware.logger_middleware import LoggerMiddleware
1819
from ..models import * # noqa: F403
1920
from .config import (
2021
AppSettings,
@@ -219,7 +220,7 @@ def create_application(
219220
allow_methods=settings.CORS_METHODS,
220221
allow_headers=settings.CORS_HEADERS,
221222
)
222-
223+
application.add_middleware(LoggerMiddleware)
223224
if isinstance(settings, EnvironmentSettings):
224225
if settings.ENVIRONMENT != EnvironmentOption.PRODUCTION:
225226
docs_router = APIRouter()

0 commit comments

Comments
 (0)