feat(log): add logger

This commit is contained in:
MingxuanGame
2025-07-28 10:38:40 +00:00
parent e369944d87
commit 1be3388524
13 changed files with 212 additions and 174 deletions

View File

@@ -1,6 +1,7 @@
from __future__ import annotations
from app.database.beatmap import BeatmapResp
from app.log import logger
from ._base import BaseFetcher
@@ -17,6 +18,9 @@ class BeatmapFetcher(BaseFetcher):
params = {"checksum": beatmap_checksum}
else:
raise ValueError("Either beatmap_id or beatmap_checksum must be provided.")
logger.opt(colors=True).debug(
f"<blue>[BeatmapFetcher]</blue> get_beatmap: <y>{params}</y>"
)
async with AsyncClient() as client:
response = await client.get(
"https://osu.ppy.sh/api/v2/beatmaps/lookup",

View File

@@ -1,6 +1,7 @@
from __future__ import annotations
from app.database.beatmapset import BeatmapsetResp
from app.log import logger
from ._base import BaseFetcher
@@ -9,6 +10,9 @@ from httpx import AsyncClient
class BeatmapsetFetcher(BaseFetcher):
async def get_beatmapset(self, beatmap_set_id: int) -> BeatmapsetResp:
logger.opt(colors=True).debug(
f"<blue>[BeatmapsetFetcher]</blue> get_beatmapset: <y>{beatmap_set_id}</y>"
)
async with AsyncClient() as client:
response = await client.get(
f"https://osu.ppy.sh/api/v2/beatmapsets/{beatmap_set_id}",

View File

@@ -3,10 +3,14 @@ from __future__ import annotations
from ._base import BaseFetcher
from httpx import AsyncClient
from loguru import logger
class OsuDotDirectFetcher(BaseFetcher):
async def get_beatmap_raw(self, beatmap_id: int) -> str:
logger.opt(colors=True).debug(
f"<blue>[OsuDotDirectFetcher]</blue> get_beatmap_raw: <y>{beatmap_id}</y>"
)
async with AsyncClient() as client:
response = await client.get(
f"https://osu.direct/api/osu/{beatmap_id}/raw",