From 16bc34d2b7894ae2fd5dfd65640940bc760a28e9 Mon Sep 17 00:00:00 2001 From: Kepka Ludovic Date: Sat, 13 Sep 2025 00:23:07 +0200 Subject: [PATCH 1/3] Ajout de log pour la notification de live --- twitchbot/live_alert.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/twitchbot/live_alert.py b/twitchbot/live_alert.py index 1292aa8..8eb8ed6 100644 --- a/twitchbot/live_alert.py +++ b/twitchbot/live_alert.py @@ -1,3 +1,5 @@ +import logging + from twitchAPI.twitch import Twitch from twitchAPI.object.api import Stream @@ -14,23 +16,30 @@ async def checkOnlineStreamer(twitch: Twitch) : for alert in alerts : stream = next((s for s in streams if s.user_login == alert.login), None) if stream : + logging.info(f'Streamer en ligne : {alert.login}') if not alert.online and alert.enable : + logging.info(f'N\'etait pas en ligne auparavant : {alert.login}') await _notifyAlert(alert, stream) alert.online = True else : + logging.info(f'Streamer hors ligne : {alert.login}') alert.online = False db.session.commit() async def _notifyAlert(alert : LiveAlert, stream : Stream): message : str = alert.message.format(stream) + logging.info(f'Message de notification : {message}') bot.loop.create_task(_sendMessage(alert.notify_channel, message)) async def _sendMessage(channel : int, message : str) : + logging.info(f'Envoi de notification : {message}') await bot.get_channel(channel).send(message) + logging.info(f'Notification envoyé') async def _retreiveStreams(twitch: Twitch, alerts : list[LiveAlert]) -> list[Stream] : streams : list[Stream] = [] async for stream in twitch.get_streams(user_login = [alert.login for alert in alerts]): streams.append(stream) + logging.info(f'Ces streams sont en ligne : {streams}') return streams From d2baa164d4bda2c5a14a1fe68f4348237e241161 Mon Sep 17 00:00:00 2001 From: Kepka Ludovic Date: Sat, 13 Sep 2025 00:25:58 +0200 Subject: [PATCH 2/3] Ajout de log pour la notification de live --- twitchbot/live_alert.py | 1 + 1 file changed, 1 insertion(+) diff --git a/twitchbot/live_alert.py b/twitchbot/live_alert.py index 8eb8ed6..ffda05c 100644 --- a/twitchbot/live_alert.py +++ b/twitchbot/live_alert.py @@ -38,6 +38,7 @@ async def _sendMessage(channel : int, message : str) : async def _retreiveStreams(twitch: Twitch, alerts : list[LiveAlert]) -> list[Stream] : streams : list[Stream] = [] + logging.info(f'Recherche de streams pour : {alerts}') async for stream in twitch.get_streams(user_login = [alert.login for alert in alerts]): streams.append(stream) logging.info(f'Ces streams sont en ligne : {streams}') From 46c927a768132eb49e66558d34846c113d8e0296 Mon Sep 17 00:00:00 2001 From: Kepka Ludovic Date: Sun, 14 Sep 2025 00:44:40 +0200 Subject: [PATCH 3/3] correction logger live logging --- twitchbot/live_alert.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/twitchbot/live_alert.py b/twitchbot/live_alert.py index ffda05c..726a130 100644 --- a/twitchbot/live_alert.py +++ b/twitchbot/live_alert.py @@ -8,6 +8,9 @@ from database.models import LiveAlert from discordbot import bot from webapp import webapp +logger = logging.getLogger('live-alert') +logger.setLevel(logging.INFO) + async def checkOnlineStreamer(twitch: Twitch) : with webapp.app_context() : @@ -16,31 +19,31 @@ async def checkOnlineStreamer(twitch: Twitch) : for alert in alerts : stream = next((s for s in streams if s.user_login == alert.login), None) if stream : - logging.info(f'Streamer en ligne : {alert.login}') + logger.info(f'Streamer en ligne : {alert.login}') if not alert.online and alert.enable : - logging.info(f'N\'etait pas en ligne auparavant : {alert.login}') + logger.info(f'N\'etait pas en ligne auparavant : {alert.login}') await _notifyAlert(alert, stream) alert.online = True else : - logging.info(f'Streamer hors ligne : {alert.login}') + logger.info(f'Streamer hors ligne : {alert.login}') alert.online = False db.session.commit() async def _notifyAlert(alert : LiveAlert, stream : Stream): message : str = alert.message.format(stream) - logging.info(f'Message de notification : {message}') + logger.info(f'Message de notification : {message}') bot.loop.create_task(_sendMessage(alert.notify_channel, message)) async def _sendMessage(channel : int, message : str) : - logging.info(f'Envoi de notification : {message}') + logger.info(f'Envoi de notification : {message}') await bot.get_channel(channel).send(message) - logging.info(f'Notification envoyé') + logger.info(f'Notification envoyé') async def _retreiveStreams(twitch: Twitch, alerts : list[LiveAlert]) -> list[Stream] : streams : list[Stream] = [] - logging.info(f'Recherche de streams pour : {alerts}') + logger.info(f'Recherche de streams pour : {alerts}') async for stream in twitch.get_streams(user_login = [alert.login for alert in alerts]): streams.append(stream) - logging.info(f'Ces streams sont en ligne : {streams}') + logger.info(f'Ces streams sont en ligne : {streams}') return streams