diff --git a/src/services/KaiqiuService.ts b/src/services/KaiqiuService.ts index a401d47..b1c7c6f 100644 --- a/src/services/KaiqiuService.ts +++ b/src/services/KaiqiuService.ts @@ -4,6 +4,7 @@ import type { ClubInfo, EventDetail, IEventInfo, MatchSummary, Player } from ".. import dayjs from "dayjs"; import utc from 'dayjs/plugin/utc'; import timezone from 'dayjs/plugin/timezone'; +import { logger } from "@/utils/logger"; dayjs.extend(utc); dayjs.extend(timezone); @@ -224,7 +225,7 @@ export class KaiqiuService { public static async login(username: string, password: string) { const loginPageRes = await fetch('https://kaiqiuwang.cc/home/do.php?ac=668g&&ref'); const cookies = loginPageRes.headers.getSetCookie().map(c => c.split(';')[0]).join('; '); - console.debug('init cookies: ', cookies); + logger.debug('Bind user', { cookies, username, password }); let $ = cheerio.load(await loginPageRes.text()); const loginsubmit = $('#loginsubmit').val()?.toString() || ''; const formhash = $('#loginform > input[type=hidden]').val()?.toString() || ''; @@ -269,7 +270,6 @@ export class KaiqiuService { .filter(cookie => !cookie?.includes('uchome_auth=deleted')) .join('; ') ].join('; '); - console.debug('auth cookies', authCookies); const networkPageReq = await fetch("https://kaiqiuwang.cc/home/network.php", { "headers": { "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8", diff --git a/src/services/uidScoreStore.ts b/src/services/uidScoreStore.ts index 2626a66..49cf6a7 100644 --- a/src/services/uidScoreStore.ts +++ b/src/services/uidScoreStore.ts @@ -1,12 +1,12 @@ +import { logger } from '@/utils/logger'; import { xcxApi } from '../utils/server'; export const getUidScore = async (uids: string[], force?: boolean): Promise> => { const entries: [string, string][] = []; - console.debug('getUidScore(%s): start', uids.length); + logger.debug('getUidScore(%s): start', uids.length); for (const uid of uids) { const profile = await xcxApi.getAdvProfile(uid, force); entries.push([uid, profile?.score ?? '']); } - console.debug('getUidScore(%s): end', uids.length); return Object.fromEntries(entries); } \ No newline at end of file diff --git a/src/services/xcxApi.ts b/src/services/xcxApi.ts index c38c10d..be87e07 100644 --- a/src/services/xcxApi.ts +++ b/src/services/xcxApi.ts @@ -43,7 +43,7 @@ export class XCXAPI { if (!cacheProfile || force) { const url = `/api/User/adv_profile?uid=${uid}`; const profile = await this.#fetch(url); - console.debug('Save profile: %s - %s', profile?.uid, profile?.realname); + logger.debug('Save profile', { uid: profile?.uid, name: profile?.realname, realname: profile?.realname }); await redis.setex(`my-kaiqiuwang:profile:${uid}`, 60 * 60 * 24, JSON.stringify(profile)); return profile; }