From 0eb1a48fca5668c7c5c35ef81d247b4511d8e78a Mon Sep 17 00:00:00 2001 From: Samlon Date: Mon, 11 Aug 2025 17:16:33 +0200 Subject: changed printing to proper logging --- cogs/music/play.py | 7 +++++-- cogs/music/play_compressed.py | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'cogs/music') diff --git a/cogs/music/play.py b/cogs/music/play.py index 5d82127..d902cdc 100644 --- a/cogs/music/play.py +++ b/cogs/music/play.py @@ -1,10 +1,13 @@ import asyncio +import logging import discord import yt_dlp from discord.ext import commands from youtubesearchpython import VideosSearch +logger = logging.getLogger(__name__) + # Suppress noise about console usage from yt-dlp yt_dlp.utils.bug_reports_message = lambda: '' @@ -45,13 +48,13 @@ class Play(commands.Cog): def after_playing(error): if error: - print(f'Player error: {error}') + logger.error(f'Player error: {error}') coro = vc.disconnect() fut = asyncio.run_coroutine_threadsafe(coro, self.bot.loop) try: fut.result() except Exception as e: - print(f'Error disconnecting: {e}') + logger.error(f'Error disconnecting: {e}', exc_info=True) source = discord.FFmpegPCMAudio(url2, **ffmpeg_options) vc.play(source, after=after_playing) diff --git a/cogs/music/play_compressed.py b/cogs/music/play_compressed.py index 0d4901c..038a15e 100644 --- a/cogs/music/play_compressed.py +++ b/cogs/music/play_compressed.py @@ -1,4 +1,5 @@ import asyncio +import logging import os import subprocess @@ -6,6 +7,8 @@ import discord from discord.ext import commands from youtubesearchpython import VideosSearch +logger = logging.getLogger(__name__) + class GrajcujZkompresowane(commands.Cog): def __init__(self, bot): @@ -20,7 +23,7 @@ class GrajcujZkompresowane(commands.Cog): modified.write(f"{title}\n".encode('utf-8')) modified.write(data) except Exception as e: - print(f"Failed to prepend title: {e}") + logger.error(f"Failed to prepend title: {e}", exc_info=True) @staticmethod def compress_audio(input_path): @@ -84,13 +87,13 @@ class GrajcujZkompresowane(commands.Cog): title = found_title def after_playing(error): if error: - print(f'Player error: {error}') + logger.error(f'Player error: {error}') coro = vc.disconnect() fut = asyncio.run_coroutine_threadsafe(coro, self.bot.loop) try: fut.result() except Exception as e: - print(f'Error disconnecting: {e}') + logger.error(f'Error disconnecting: {e}', exc_info=True) if vc.is_playing() or vc.is_paused(): vc.stop() -- cgit v1.2.3