Skip to content

Commit 88353ff

Browse files
georgeglarsonclaude
andcommitted
fix: improve request logging with local timezone and noise filtering
Switch morgan to Eastern time, skip static asset and scanner probe logging to reduce noise. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 62c3308 commit 88353ff

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/server/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@ setDb(db);
1313

1414
const app = createApp(db);
1515

16-
app.use(morgan("[:date[iso]] :remote-addr :method :url :status :response-time[0]ms"));
16+
morgan.token("localtime", () => new Date().toLocaleString("en-US", { timeZone: "America/New_York", hour12: true }));
17+
app.use(morgan("[:localtime] :remote-addr :method :url :status :response-time[0]ms", {
18+
skip: (req) => {
19+
const url = req.originalUrl ?? "";
20+
// Skip static assets
21+
if (url.startsWith("/assets/")) return true;
22+
// Skip scanner probes (wp-admin, .env, .git, php, etc.)
23+
if (/\.(env|git|php|asp|cgi)|wp-|phpmyadmin|xmlrpc/i.test(url)) return true;
24+
return false;
25+
},
26+
}));
1727

1828
// Serve static client build in production
1929
const clientDist = path.resolve(import.meta.dirname, "../../dist/client");

0 commit comments

Comments
 (0)