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
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:
@ -1,6 +1,7 @@
|
||||
# nhn_prj/middleware.py
|
||||
import logging
|
||||
import time
|
||||
import sys
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -15,11 +16,13 @@ class RequestLoggingMiddleware:
|
||||
# 요청 시작 시간
|
||||
start_time = time.time()
|
||||
|
||||
# 요청 정보 로깅
|
||||
logger.info(
|
||||
# 표준출력으로 직접 출력
|
||||
print(
|
||||
f"[REQUEST] {request.method} {request.path} "
|
||||
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 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)
|
||||
@ -37,10 +40,12 @@ class RequestLoggingMiddleware:
|
||||
duration = time.time() - start_time
|
||||
|
||||
# 응답 정보 로깅
|
||||
logger.info(
|
||||
print(
|
||||
f"[RESPONSE] {request.method} {request.path} "
|
||||
f"| Status: {response.status_code} "
|
||||
f"| Duration: {duration:.3f}s"
|
||||
f"| Duration: {duration:.3f}s",
|
||||
file=sys.stdout,
|
||||
flush=True
|
||||
)
|
||||
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user