From 6cabd370fc9d22e5b15c4627eaf1660ae7cafc33 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 1 Apr 2024 19:53:19 +0200 Subject: Merge redirect information into standard log line --- src/app.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/app.ts b/src/app.ts index e0fe2e8..1b8bcf7 100644 --- a/src/app.ts +++ b/src/app.ts @@ -129,6 +129,7 @@ export const server = { const pathname = url.pathname.replace(/\/\/+/g, "/"); const endTimer = metrics.requestDuration.startTimer({ path: pathname }); let status; + let newpath; const transaction = Sentry.startTransaction({ name: pathname, op: "http.server", @@ -203,7 +204,7 @@ export const server = { }); } else { if (files.has(pathname + "/")) { - log.info(`Redirecting to: ${pathname + "/"}`); + newpath = pathname + "/"; metrics.requests.inc({ method: request.method, path: pathname, @@ -211,7 +212,7 @@ export const server = { }); return new Response("", { status: status, - headers: { location: pathname + "/" }, + headers: { location: newpath }, }); } metrics.requests.inc({ @@ -249,7 +250,7 @@ export const server = { const seconds = endTimer(); metrics.requestDuration.observe(seconds); transaction.finish(); - console.log(request.method, status, pathname); + console.log(request.method, status, pathname, newpath ? newpath : ""); } }, } satisfies Serve; -- cgit 1.4.1