From 760a66d70b20c44c9ca2bf9eb884574a05771d52 Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Sun, 11 Aug 2024 11:39:28 +0200 Subject: [PATCH] refactor: Adjust logging logic to match rest of repo --- reaper/cogs/sentiment_analyzer.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/reaper/cogs/sentiment_analyzer.py b/reaper/cogs/sentiment_analyzer.py index 09817db..f1495c5 100644 --- a/reaper/cogs/sentiment_analyzer.py +++ b/reaper/cogs/sentiment_analyzer.py @@ -1,6 +1,14 @@ +import logging +import coloredlogs + +logger = logging.getLogger(__name__) +coloredlogs.install( + level="DEBUG", logger=logger, fmt="%(asctime)s - %(levelname)s - %(message)s" +) + + from transformers import pipeline from discord.ext import commands -import logging import asyncio import random from util import globals @@ -46,7 +54,7 @@ async def on_message(self, message): self.sentiment, message.content ) # need to do this otherwise the bot will not do anything until this is done except Exception as e: - logging.error(f"Error in sentiment analyzer: {e}") + logger.error(f"Error in sentiment analyzer: {e}") return self.bot.cached_sentiment[message.channel.id][result[0]["label"]] += 1