From 6523096119182bd6a643d482a1650f8f7b6ba5fd Mon Sep 17 00:00:00 2001 From: oralcoder Date: Wed, 22 Oct 2025 03:52:28 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main.py b/main.py index 26f5dd6..66c2356 100644 --- a/main.py +++ b/main.py @@ -43,6 +43,7 @@ @app.get("/") def read_root(): + logger.debug("main endpoint") return {"message": "MES Copilot API is running"} From f8dfd58eef6714c2abf025aef1b3a12f724065c4 Mon Sep 17 00:00:00 2001 From: oralcoder <79191260+oralcoder@users.noreply.github.com> Date: Wed, 22 Oct 2025 04:13:01 +0900 Subject: [PATCH 2/2] Use conditional logger.debug to avoid unnecessary logging work --- main.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 66c2356..2f3a125 100644 --- a/main.py +++ b/main.py @@ -10,21 +10,21 @@ # 로깅 설정 logging.basicConfig( - level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" + level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' ) logger = logging.getLogger(__name__) Base.metadata.create_all(bind=engine) -app = FastAPI(title="MES Copilot Demo") +app = FastAPI(title='MES Copilot Demo') # CORS 설정 app.add_middleware( CORSMiddleware, - allow_origins=["http://localhost"], # 허용할 도메인 + allow_origins=['http://localhost'], # 허용할 도메인 allow_credentials=True, - allow_methods=["*"], - allow_headers=["*"], + allow_methods=['*'], + allow_headers=['*'], ) # Add custom middleware @@ -41,10 +41,12 @@ app.include_router(weather_router) -@app.get("/") +@app.get('/') def read_root(): - logger.debug("main endpoint") - return {"message": "MES Copilot API is running"} + # DEBUG 레벨 로그는 비용이 들 수 있는 연산(포맷팅 등)을 하기 전에 레벨을 확인하는 것이 더 효율적입니다. + if logger.isEnabledFor(logging.DEBUG): + logger.debug('main endpoint') + return {'message': 'MES Copilot API is running'} unused_var = 10