From eb83e221e432676c6d75f43ce4f99cdd4961241f Mon Sep 17 00:00:00 2001 From: monoid Date: Sun, 7 Apr 2024 22:29:26 +0900 Subject: [PATCH] fix server log bug --- packages/server/src/route/comic.ts | 1 - packages/server/src/route/contents.ts | 1 - packages/server/src/server.ts | 10 ++++++---- packages/server/src/util/zipwrap.ts | 2 -- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/server/src/route/comic.ts b/packages/server/src/route/comic.ts index 7991e4c..1ed4dc3 100644 --- a/packages/server/src/route/comic.ts +++ b/packages/server/src/route/comic.ts @@ -103,7 +103,6 @@ async function renderZipImage(ctx: Context, path: string, page: number) { ctx.body = nodeReadableStream; ctx.response.length = entry.uncompressedSize; - // console.log(`${entry.name}'s ${page}:${entry.size}`); ctx.response.type = entry.filename.split(".").pop() as string; ctx.status = 200; ctx.set("Date", new Date().toUTCString()); diff --git a/packages/server/src/route/contents.ts b/packages/server/src/route/contents.ts index 5e407e3..9a2068f 100644 --- a/packages/server/src/route/contents.ts +++ b/packages/server/src/route/contents.ts @@ -24,7 +24,6 @@ const ContentIDHandler = (controller: DocumentAccessor) => async (ctx: Context, } ctx.body = document; ctx.type = "json"; - console.log(document.additional); }; const ContentTagIDHandler = (controller: DocumentAccessor) => async (ctx: Context, next: Next) => { const num = Number.parseInt(ctx.params.num); diff --git a/packages/server/src/server.ts b/packages/server/src/server.ts index bf5bd08..f1afd78 100644 --- a/packages/server/src/server.ts +++ b/packages/server/src/server.ts @@ -98,12 +98,14 @@ class ServerApplication { if (setting.mode === "development") { let mm_count = 0; app.use(async (ctx, next) => { - console.log(`==========================${mm_count++}`); - const ip = ctx.get("X-Real-IP") ?? ctx.ip; + console.log(`=== Request No ${mm_count++} \t===`); + const ip = ctx.get("X-Real-IP").length > 0 ? ctx.get("X-Real-IP") : ctx.ip; const fromClient = ctx.state.user.username === "" ? ip : ctx.state.user.username; - console.log(`${fromClient} : ${ctx.method} ${ctx.url}`); + console.log(`${mm_count} ${fromClient} : ${ctx.method} ${ctx.url}`); + const start = Date.now(); await next(); - // console.log(`404`); + const end = Date.now(); + console.log(`${mm_count} ${fromClient} : ${ctx.method} ${ctx.url} ${ctx.status} ${end - start}ms`); }); } app.use(router.routes()); diff --git a/packages/server/src/util/zipwrap.ts b/packages/server/src/util/zipwrap.ts index 187655f..5410cd4 100644 --- a/packages/server/src/util/zipwrap.ts +++ b/packages/server/src/util/zipwrap.ts @@ -39,9 +39,7 @@ export async function readZip(path: string): Promise<{ return { reader, handle: fd }; } export async function entriesByNaturalOrder(zip: ZipReader) { - // console.log(zip); const entries = await zip.getEntries(); - // console.log(entries.map((v) => v.filename)); const ret = orderBy(entries, (v) => v.filename); return ret; }