v0.0.6 | Use print with flush for immediate stdout logging
All checks were successful
Build And Test / build-and-push (push) Successful in 1m1s

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-14 11:36:16 +09:00
parent 26f50b7f80
commit 4f9cb872a9
2 changed files with 12 additions and 7 deletions

View File

@ -1,6 +1,7 @@
# nhn_prj/middleware.py # nhn_prj/middleware.py
import logging import logging
import time import time
import sys
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -15,11 +16,13 @@ class RequestLoggingMiddleware:
# 요청 시작 시간 # 요청 시작 시간
start_time = time.time() start_time = time.time()
# 요청 정보 로깅 # 표준출력으로 직접 출력
logger.info( print(
f"[REQUEST] {request.method} {request.path} " f"[REQUEST] {request.method} {request.path} "
f"| Host: {request.get_host()} " f"| Host: {request.get_host()} "
f"| IP: {self.get_client_ip(request)}" f"| IP: {self.get_client_ip(request)}",
file=sys.stdout,
flush=True
) )
# 헤더 로깅 (디버깅용) # 헤더 로깅 (디버깅용)
@ -28,7 +31,7 @@ class RequestLoggingMiddleware:
if k.lower().startswith('x-nhn') if k.lower().startswith('x-nhn')
} }
if nhn_headers: if nhn_headers:
logger.info(f"[HEADERS] NHN Headers: {nhn_headers}") print(f"[HEADERS] NHN Headers: {nhn_headers}", file=sys.stdout, flush=True)
# 응답 처리 # 응답 처리
response = self.get_response(request) response = self.get_response(request)
@ -37,10 +40,12 @@ class RequestLoggingMiddleware:
duration = time.time() - start_time duration = time.time() - start_time
# 응답 정보 로깅 # 응답 정보 로깅
logger.info( print(
f"[RESPONSE] {request.method} {request.path} " f"[RESPONSE] {request.method} {request.path} "
f"| Status: {response.status_code} " f"| Status: {response.status_code} "
f"| Duration: {duration:.3f}s" f"| Duration: {duration:.3f}s",
file=sys.stdout,
flush=True
) )
return response return response

View File

@ -1 +1 @@
v0.0.5 v0.0.6