From 63ca1fd2bd344477c13d0aabb184dc481970206f Mon Sep 17 00:00:00 2001 From: Specoolazius Date: Wed, 30 Mar 2022 21:50:07 +0200 Subject: [PATCH] new logging handlers --- bot/botclient.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bot/botclient.py b/bot/botclient.py index bb0acb0..af03120 100644 --- a/bot/botclient.py +++ b/bot/botclient.py @@ -159,11 +159,17 @@ class BotClient(discord.Bot, ABC): logger = logging.getLogger('discord') logger.setLevel(level) - handler = logging.FileHandler(filename=f'{os.path.join(*path_list, "") or ""}discord.log', encoding='utf-8', - mode='w') - handler.setFormatter(logging.Formatter(fmt='[%(asctime)s] - %(levelname)s: %(name)s: %(message)s')) + formatter = logging.Formatter(fmt='[%(asctime)s] - %(levelname)s: %(name)s: %(message)s') + + file_handler = logging.FileHandler(filename=f'{os.path.join(*path_list, "") or ""}discord.log', + encoding='utf-8', mode='w') + file_handler.setFormatter(formatter) + logger.addHandler(file_handler) + + console_handler = logging.StreamHandler() + console_handler.setFormatter(formatter) + logger.addHandler(console_handler) - logger.addHandler(handler) return logger async def on_ready(self) -> None: