Add loggers

This commit is contained in:
2024-08-10 04:26:52 +02:00
parent e7520d5ffd
commit 5ad15320f7
3 changed files with 15 additions and 3 deletions

View File

@@ -1,11 +1,15 @@
from asyncio import gather from asyncio import gather
import logging
from services.discord import start_discord_sevice from services.discord import start_discord_sevice
from services.twitch import start_twitch_service from services.twitch import start_twitch_service
logger = logging.getLogger(__name__)
async def main(): async def main():
print("Starting services...") logger.info("Starting services...")
await gather( await gather(
start_discord_sevice(), start_discord_sevice(),
start_twitch_service() start_twitch_service()

View File

@@ -1,4 +1,5 @@
import asyncio import asyncio
import logging
import discord import discord
from discord.abc import Messageable from discord.abc import Messageable
@@ -10,6 +11,9 @@ from services.games_list import GameList, GameItem
from config import config from config import config
logger = logging.getLogger(__name__)
class DiscordClient(discord.Client): class DiscordClient(discord.Client):
def __init__(self) -> None: def __init__(self) -> None:
intents = discord.Intents.default() intents = discord.Intents.default()
@@ -109,7 +113,7 @@ async def delete(interaction: discord.Interaction, game: str):
async def start_discord_sevice(): async def start_discord_sevice():
print("Starting Discord service...") logger.info("Starting Discord service...")
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
await loop.run_in_executor(None, client.run, config.DISCORD_BOT_TOKEN) await loop.run_in_executor(None, client.run, config.DISCORD_BOT_TOKEN)

View File

@@ -1,6 +1,7 @@
from asyncio import Lock, sleep from asyncio import Lock, sleep
from datetime import datetime from datetime import datetime
import json import json
import logging
from twitchAPI.helper import first from twitchAPI.helper import first
from twitchAPI.eventsub.webhook import EventSubWebhook from twitchAPI.eventsub.webhook import EventSubWebhook
@@ -16,6 +17,9 @@ from config import config
from services.notification import notify from services.notification import notify
logger = logging.getLogger(__name__)
class State(BaseModel): class State(BaseModel):
title: str title: str
category: str category: str
@@ -188,7 +192,7 @@ class TwitchService:
@classmethod @classmethod
async def start(cls): async def start(cls):
print("Starting Twitch service...") logger.info("Starting Twitch service...")
twith = await cls.authorize() twith = await cls.authorize()
await cls(twith).run() await cls(twith).run()