From 28a0667da65ea1499f35f03f9ce4054eb95c07e0 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 8 Feb 2025 12:49:42 +0000 Subject: [PATCH 1/3] fix: minor logging issue --- application/api/answer/routes.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/application/api/answer/routes.py b/application/api/answer/routes.py index 31aa43ac..e877fac5 100644 --- a/application/api/answer/routes.py +++ b/application/api/answer/routes.py @@ -1,7 +1,6 @@ import asyncio import datetime import json -import logging import os import traceback @@ -19,7 +18,6 @@ from application.llm.llm_creator import LLMCreator from application.retriever.retriever_creator import RetrieverCreator from application.utils import check_required_fields, limit_chat_history -logger = logging.getLogger(__name__) mongo = MongoDB.get_client() db = mongo["docsgpt"] @@ -262,8 +260,8 @@ def complete_stream( data = json.dumps({"type": "end"}) yield f"data: {data}\n\n" except Exception as e: - logger.error(f"Error in stream: {str(e)}") - logger.error(traceback.format_exc()) + current_app.logger.error(f"Error in stream: {str(e)}") + current_app.logger.error(traceback.format_exc()) data = json.dumps( { "type": "error", From ad77fe1116fad7697f1bebee0af843910967cd38 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 8 Feb 2025 18:07:03 +0000 Subject: [PATCH 2/3] fix: logging in submodules --- application/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/app.py b/application/app.py index d7727001..4db18e2d 100644 --- a/application/app.py +++ b/application/app.py @@ -2,12 +2,13 @@ import platform import dotenv from flask import Flask, redirect, request +from application.core.logging_config import setup_logging +setup_logging() from application.api.answer.routes import answer from application.api.internal.routes import internal from application.api.user.routes import user from application.celery_init import celery -from application.core.logging_config import setup_logging from application.core.settings import settings from application.extensions import api @@ -17,7 +18,6 @@ if platform.system() == "Windows": pathlib.PosixPath = pathlib.WindowsPath dotenv.load_dotenv() -setup_logging() app = Flask(__name__) app.register_blueprint(user) From f4cb48ed0d4f23c21179d42ceca7fa35ca16481c Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 8 Feb 2025 19:29:54 +0000 Subject: [PATCH 3/3] fix: logging --- application/app.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/application/app.py b/application/app.py index 4db18e2d..4eb40331 100644 --- a/application/app.py +++ b/application/app.py @@ -5,16 +5,16 @@ from flask import Flask, redirect, request from application.core.logging_config import setup_logging setup_logging() -from application.api.answer.routes import answer -from application.api.internal.routes import internal -from application.api.user.routes import user -from application.celery_init import celery -from application.core.settings import settings -from application.extensions import api +from application.api.answer.routes import answer # noqa: E402 +from application.api.internal.routes import internal # noqa: E402 +from application.api.user.routes import user # noqa: E402 +from application.celery_init import celery # noqa: E402 +from application.core.settings import settings # noqa: E402 +from application.extensions import api # noqa: E402 + if platform.system() == "Windows": import pathlib - pathlib.PosixPath = pathlib.WindowsPath dotenv.load_dotenv()