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 <max@aequito.sh>
This commit is contained in:
Max R. Carrara 2025-03-14 00:10:05 +01:00
parent 1dfa03bc17
commit 18f057793e

View file

@ -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 = }")