Fixed logging but not configurable anymore.

This commit is contained in:
Uwe Pfeifer 2022-08-17 15:32:47 +02:00
parent 7a43266291
commit 221f8ceee5

View file

@ -9,7 +9,11 @@ from discord.ext import commands
import logging import logging
# Logging # Logging
loghandler = logging.FileHandler(filename='bot.log', encoding='utf-8', mode='w') logger = logging.getLogger('discord')
logger.setLevel(logging.INFO)
handler = logging.FileHandler(filename='bot.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
# The bots' description # The bots' description
description = '''Testing this bot stuff :)''' description = '''Testing this bot stuff :)'''
@ -26,11 +30,10 @@ config = configparser.ConfigParser()
config.read('bot.ini') config.read('bot.ini')
bottoken = config['General']['bottoken'] bottoken = config['General']['bottoken']
loglevel = logging.getLevelName(config['General']['loglevel'])
# Setting up commands.Bot # Setting up commands.Bot
bot = commands.Bot(command_prefix='.', description=description, intents=intents, log_handler=loghandler, log_level=loglevel) bot = commands.Bot(command_prefix='.', description=description, intents=intents)
@bot.event @bot.event