From a9804e25661cad250855b6a1ca6cb08582200720 Mon Sep 17 00:00:00 2001 From: Sihyeon Jang Date: Thu, 3 Jul 2025 08:25:39 +0900 Subject: [PATCH] refactor: replace print statements with appropriate logging levels Signed-off-by: Sihyeon Jang --- backend/open_webui/main.py | 2 +- backend/open_webui/tasks.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 544756a6e8..cecb10e3cf 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -1468,7 +1468,7 @@ async def list_tasks_by_chat_id_endpoint( task_ids = await list_task_ids_by_chat_id(request, chat_id) - print(f"Task IDs for chat {chat_id}: {task_ids}") + log.debug(f"Task IDs for chat {chat_id}: {task_ids}") return {"task_ids": task_ids} diff --git a/backend/open_webui/tasks.py b/backend/open_webui/tasks.py index 2d3955f0a2..8ba66b2f57 100644 --- a/backend/open_webui/tasks.py +++ b/backend/open_webui/tasks.py @@ -3,10 +3,17 @@ import asyncio from typing import Dict from uuid import uuid4 import json +import logging from redis.asyncio import Redis from fastapi import Request from typing import Dict, List, Optional +from open_webui.env import SRC_LOG_LEVELS + + +log = logging.getLogger(__name__) +log.setLevel(SRC_LOG_LEVELS["MAIN"]) + # A dictionary to keep track of active tasks tasks: Dict[str, asyncio.Task] = {} chat_tasks = {} @@ -38,7 +45,7 @@ async def redis_task_command_listener(app): if local_task: local_task.cancel() except Exception as e: - print(f"Error handling distributed task command: {e}") + log.exception(f"Error handling distributed task command: {e}") ### ------------------------------