From f38428ab23a1ec1f6ee22b976189d7e9da9b9167 Mon Sep 17 00:00:00 2001 From: foxfire52 Date: Fri, 15 Nov 2024 07:38:51 +0100 Subject: Improve logging implementation (#2347) --- g4f/gui/server/api.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'g4f/gui/server/api.py') diff --git a/g4f/gui/server/api.py b/g4f/gui/server/api.py index 7aac650a..dafcb5d4 100644 --- a/g4f/gui/server/api.py +++ b/g4f/gui/server/api.py @@ -19,6 +19,8 @@ from g4f.Provider import ProviderType, __providers__, __map__ from g4f.providers.base_provider import ProviderModelMixin, FinishReason from g4f.providers.conversation import BaseConversation +logger = logging.getLogger(__name__) + # Define the directory for generated images images_dir = "./generated_images" @@ -155,7 +157,7 @@ class Api: conversations[provider][conversation_id] = chunk yield self._format_json("conversation", conversation_id) elif isinstance(chunk, Exception): - logging.exception(chunk) + logger.exception(chunk) yield self._format_json("message", get_error_message(chunk)) elif isinstance(chunk, ImagePreview): yield self._format_json("preview", chunk.to_string()) @@ -165,7 +167,7 @@ class Api: elif not isinstance(chunk, FinishReason): yield self._format_json("content", str(chunk)) except Exception as e: - logging.exception(e) + logger.exception(e) yield self._format_json('error', get_error_message(e)) async def _copy_images(self, images: list[str], cookies: Optional[Cookies] = None): -- cgit v1.2.3