mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-07 09:52:30 -05:00
Audio cleanup (#5618)
* add different logging level callbacks for task exception logging * Add callback to tasks which didn't have them * The boring stuff - (apply .trace() and .verbose() to audio, stop using debug_exc_log, delete audio_logging.py) * Unsured import cleanup * use new lavalink method * return so it doesn't log this twice. * improve logging on main event handler
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import datetime
|
||||
import logging
|
||||
import math
|
||||
import re
|
||||
@@ -17,7 +16,6 @@ from redbot.core.utils import AsyncIter
|
||||
from redbot.core.utils.chat_formatting import box, escape
|
||||
|
||||
from ...audio_dataclasses import LocalPath, Query
|
||||
from ...audio_logging import IS_DEBUG
|
||||
from ..abc import MixinMeta
|
||||
from ..cog_utils import CompositeMetaClass
|
||||
|
||||
@@ -163,8 +161,7 @@ class FormattingUtilities(MixinMeta, metaclass=CompositeMetaClass):
|
||||
f"{search_choice.title} {search_choice.author} {search_choice.uri} {str(query)}",
|
||||
query_obj=query,
|
||||
):
|
||||
if IS_DEBUG:
|
||||
log.debug("Query is not allowed in %r (%d)", ctx.guild.name, ctx.guild.id)
|
||||
log.debug("Query is not allowed in %r (%d)", ctx.guild.name, ctx.guild.id)
|
||||
self.update_player_lock(ctx, False)
|
||||
return await self.send_embed_msg(
|
||||
ctx, title=_("This track is not allowed in this server.")
|
||||
|
||||
@@ -20,7 +20,7 @@ from redbot.core.utils import AsyncIter
|
||||
from redbot.core.utils.chat_formatting import humanize_number
|
||||
|
||||
from ...apis.playlist_interface import get_all_playlist_for_migration23
|
||||
from ...utils import PlaylistScope, task_callback
|
||||
from ...utils import PlaylistScope, task_callback_trace
|
||||
from ..abc import MixinMeta
|
||||
from ..cog_utils import CompositeMetaClass, DataReader
|
||||
|
||||
@@ -36,7 +36,7 @@ class MiscellaneousUtilities(MixinMeta, metaclass=CompositeMetaClass):
|
||||
) -> asyncio.Task:
|
||||
"""Non blocking version of clear_react."""
|
||||
task = self.bot.loop.create_task(self.clear_react(message, emoji))
|
||||
task.add_done_callback(task_callback)
|
||||
task.add_done_callback(task_callback_trace)
|
||||
return task
|
||||
|
||||
async def maybe_charge_requester(self, ctx: commands.Context, jukebox_price: int) -> bool:
|
||||
|
||||
@@ -15,7 +15,6 @@ from redbot.core.utils import AsyncIter
|
||||
from redbot.core.utils.chat_formatting import bold, escape
|
||||
|
||||
from ...audio_dataclasses import _PARTIALLY_SUPPORTED_MUSIC_EXT, Query
|
||||
from ...audio_logging import IS_DEBUG, debug_exc_log
|
||||
from ...errors import QueryUnauthorized, SpotifyFetchError, TrackEnqueueError
|
||||
from ...utils import Notifier
|
||||
from ..abc import MixinMeta
|
||||
@@ -122,8 +121,8 @@ class PlayerUtilities(MixinMeta, metaclass=CompositeMetaClass):
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
log.debug("Current requester is %s", player.current.requester)
|
||||
return player.current.requester.id == member.id
|
||||
except Exception as err:
|
||||
debug_exc_log(log, err, "Caught error in `is_requester`")
|
||||
except Exception as exc:
|
||||
log.trace("Caught error in `is_requester`", exc_info=exc)
|
||||
return False
|
||||
|
||||
async def _skip_action(self, ctx: commands.Context, skip_to_track: int = None) -> None:
|
||||
@@ -451,8 +450,7 @@ class PlayerUtilities(MixinMeta, metaclass=CompositeMetaClass):
|
||||
f"{track.title} {track.author} {track.uri} " f"{str(query)}",
|
||||
query_obj=query,
|
||||
):
|
||||
if IS_DEBUG:
|
||||
log.debug("Query is not allowed in %r (%d)", ctx.guild.name, ctx.guild.id)
|
||||
log.debug("Query is not allowed in %r (%d)", ctx.guild.name, ctx.guild.id)
|
||||
continue
|
||||
elif guild_data["maxlength"] > 0:
|
||||
if self.is_track_length_allowed(track, guild_data["maxlength"]):
|
||||
@@ -541,8 +539,7 @@ class PlayerUtilities(MixinMeta, metaclass=CompositeMetaClass):
|
||||
),
|
||||
query_obj=query,
|
||||
):
|
||||
if IS_DEBUG:
|
||||
log.debug("Query is not allowed in %r (%d)", ctx.guild.name, ctx.guild.id)
|
||||
log.debug("Query is not allowed in %r (%d)", ctx.guild.name, ctx.guild.id)
|
||||
self.update_player_lock(ctx, False)
|
||||
return await self.send_embed_msg(
|
||||
ctx, title=_("This track is not allowed in this server.")
|
||||
|
||||
@@ -24,7 +24,6 @@ from redbot.core.utils.predicates import ReactionPredicate
|
||||
|
||||
from ...apis.playlist_interface import Playlist, PlaylistCompat23, create_playlist
|
||||
from ...audio_dataclasses import _PARTIALLY_SUPPORTED_MUSIC_EXT, Query
|
||||
from ...audio_logging import debug_exc_log
|
||||
from ...errors import TooManyMatches, TrackEnqueueError
|
||||
from ...utils import Notifier, PlaylistScope
|
||||
from ..abc import MixinMeta
|
||||
@@ -434,15 +433,15 @@ class PlaylistUtilities(MixinMeta, metaclass=CompositeMetaClass):
|
||||
raise e
|
||||
|
||||
track = result.tracks[0]
|
||||
except Exception as err:
|
||||
debug_exc_log(log, err, "Failed to get track for %r", song_url)
|
||||
except Exception as exc:
|
||||
log.verbose("Failed to get track for %r", song_url, exc_info=exc)
|
||||
continue
|
||||
try:
|
||||
track_obj = self.get_track_json(player, other_track=track)
|
||||
track_list.append(track_obj)
|
||||
successful_count += 1
|
||||
except Exception as err:
|
||||
debug_exc_log(log, err, "Failed to create track for %r", track)
|
||||
except Exception as exc:
|
||||
log.verbose("Failed to create track for %r", track, exc_info=exc)
|
||||
continue
|
||||
if (track_count % 2 == 0) or (track_count == len(uploaded_track_list)):
|
||||
await notifier.notify_user(
|
||||
@@ -695,8 +694,10 @@ class PlaylistUtilities(MixinMeta, metaclass=CompositeMetaClass):
|
||||
return 0, []
|
||||
try:
|
||||
data = json.loads(await response.read())
|
||||
except Exception:
|
||||
log.exception("Curated playlist couldn't be parsed, report this error.")
|
||||
except Exception as exc:
|
||||
log.error(
|
||||
"Curated playlist couldn't be parsed, report this error.", exc_info=exc
|
||||
)
|
||||
data = {}
|
||||
web_version = data.get("version", 0)
|
||||
entries = data.get("entries", [])
|
||||
|
||||
Reference in New Issue
Block a user