mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-08 10:22:31 -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:
@@ -16,7 +16,6 @@ from redbot.core.commands import Cog
|
||||
from redbot.core.i18n import Translator
|
||||
|
||||
from ..audio_dataclasses import Query
|
||||
from ..audio_logging import IS_DEBUG, debug_exc_log
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .. import Audio
|
||||
@@ -76,18 +75,17 @@ class GlobalCacheWrapper:
|
||||
params={"query": query},
|
||||
) as r:
|
||||
search_response = await r.json(loads=json.loads)
|
||||
if IS_DEBUG and "x-process-time" in r.headers:
|
||||
log.debug(
|
||||
"GET || Ping %s || Status code %d || %s",
|
||||
r.headers.get("x-process-time"),
|
||||
r.status,
|
||||
query,
|
||||
)
|
||||
log.trace(
|
||||
"GET || Ping %s || Status code %d || %s",
|
||||
r.headers.get("x-process-time"),
|
||||
r.status,
|
||||
query,
|
||||
)
|
||||
if "tracks" not in search_response:
|
||||
return {}
|
||||
return search_response
|
||||
except Exception as err:
|
||||
debug_exc_log(log, err, "Failed to Get query: %s/%s", api_url, query)
|
||||
except Exception as exc:
|
||||
log.trace("Failed to Get query: %s/%s", api_url, query, exc_info=exc)
|
||||
return {}
|
||||
|
||||
async def get_spotify(self, title: str, author: Optional[str]) -> dict:
|
||||
@@ -108,19 +106,18 @@ class GlobalCacheWrapper:
|
||||
params=params,
|
||||
) as r:
|
||||
search_response = await r.json(loads=json.loads)
|
||||
if IS_DEBUG and "x-process-time" in r.headers:
|
||||
log.debug(
|
||||
"GET/spotify || Ping %s || Status code %d || %s - %s",
|
||||
r.headers.get("x-process-time"),
|
||||
r.status,
|
||||
title,
|
||||
author,
|
||||
)
|
||||
log.trace(
|
||||
"GET/spotify || Ping %s || Status code %d || %s - %s",
|
||||
r.headers.get("x-process-time"),
|
||||
r.status,
|
||||
title,
|
||||
author,
|
||||
)
|
||||
if "tracks" not in search_response:
|
||||
return {}
|
||||
return search_response
|
||||
except Exception as err:
|
||||
debug_exc_log(log, err, "Failed to Get query: %s", api_url)
|
||||
except Exception as exc:
|
||||
log.trace("Failed to Get query: %s", api_url, exc_info=exc)
|
||||
return {}
|
||||
|
||||
async def post_call(self, llresponse: LoadResult, query: Optional[Query]) -> None:
|
||||
@@ -145,15 +142,14 @@ class GlobalCacheWrapper:
|
||||
params={"query": query},
|
||||
) as r:
|
||||
await r.read()
|
||||
if IS_DEBUG and "x-process-time" in r.headers:
|
||||
log.debug(
|
||||
"GET || Ping %s || Status code %d || %s",
|
||||
r.headers.get("x-process-time"),
|
||||
r.status,
|
||||
query,
|
||||
)
|
||||
except Exception as err:
|
||||
debug_exc_log(log, err, "Failed to post query: %s", query)
|
||||
log.trace(
|
||||
"GET || Ping %s || Status code %d || %s",
|
||||
r.headers.get("x-process-time"),
|
||||
r.status,
|
||||
query,
|
||||
)
|
||||
except Exception as exc:
|
||||
log.trace("Failed to post query: %s", query, exc_info=exc)
|
||||
await asyncio.sleep(0)
|
||||
|
||||
async def update_global(self, llresponse: LoadResult, query: Optional[Query] = None):
|
||||
|
||||
Reference in New Issue
Block a user