From 4b62762c1311305f410ddd797b75597562d4773b Mon Sep 17 00:00:00 2001 From: mihalin Date: Thu, 30 Jun 2022 01:28:03 +0300 Subject: [PATCH] logging print datetime --- olgram/settings.py | 3 ++- server/custom.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/olgram/settings.py b/olgram/settings.py index ec06ee4..6ca0fd0 100644 --- a/olgram/settings.py +++ b/olgram/settings.py @@ -105,7 +105,8 @@ class ServerSettings(AbstractSettings): return int(timedelta(days=1).total_seconds() * 1000.0) -logging.basicConfig(level=os.environ.get("LOGLEVEL", "WARNING")) +logging.basicConfig(level=os.environ.get("LOGLEVEL", "WARNING"), + format='%(asctime)s %(levelname)-8s %(message)s') class BotSettings(AbstractSettings): diff --git a/server/custom.py b/server/custom.py index db7456d..674e9f0 100644 --- a/server/custom.py +++ b/server/custom.py @@ -131,6 +131,8 @@ async def handle_user_message(message: types.Message, super_chat_id: int, bot): await send_to_superchat(is_super_group, message, super_chat_id, bot) except (exceptions.Unauthorized, exceptions.ChatNotFound): return SendMessage(chat_id=message.chat.id, text=_("Не удаётся связаться с владельцем бота")) + except exceptions.MessageToForwardNotFound: + _logger.error("(exception) Message to forward not found") bot.incoming_messages_count = F("incoming_messages_count") + 1 await bot.save(update_fields=["incoming_messages_count"])