From 18f057793ea582ce3bb959ba635b9d578d1fbb12 Mon Sep 17 00:00:00 2001 From: "Max R. Carrara" Date: Fri, 14 Mar 2025 00:10:05 +0100 Subject: [PATCH] bot: main: fix root logger not being initialised correctly tl;dr: shouldn't have passed __name__ to logging.getLogger() This also makes it so that discord.py is logging everything as expected, which it didn't do before. Signed-off-by: Max R. Carrara --- src/bot/main.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/bot/main.py b/src/bot/main.py index 338ec13..c3a0b23 100644 --- a/src/bot/main.py +++ b/src/bot/main.py @@ -11,11 +11,11 @@ from discord.ext import commands from bot.env import Environment -_log: logging.Logger +_log = logging.getLogger(__name__) -def setup_logging() -> logging.Logger: - root_logger = logging.getLogger(__name__) +def setup_logging(): + root_logger = logging.getLogger() log_level_map = { "NOTSET": logging.NOTSET, @@ -57,8 +57,6 @@ def setup_logging() -> logging.Logger: log_error_file_handler.setLevel(logging.ERROR) root_logger.addHandler(log_error_file_handler) - return root_logger - def setup_bot() -> commands.Bot: intents = discord.Intents.all() @@ -181,7 +179,7 @@ async def main(): await bot.start(token=token, reconnect=True) -_log = setup_logging() +setup_logging() _log.debug("Logging initialised") _log.debug(f"{sys.argv = }")