Skip to content

Commit 5c7b643

Browse files
committed
Add request logging middleware to nodejs-express
Log every incoming request with timestamp, method, and URL to help debug the logs system. Made-with: Cursor
1 parent 0c31d5c commit 5c7b643

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

nodejs-express/src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ if (process.env.ENABLE_BENCHMARKING) {
2424
);
2525
}
2626

27+
index.use((req, res, next) => {
28+
console.log(`${new Date().toISOString()} ${req.method} ${req.url}`);
29+
next();
30+
});
31+
2732
index.get("/", (req, res) => {
2833
res.set("Content-type", "text/plain");
2934
res.status(200).send(cowsay.say({ text: "Hello World" }));

0 commit comments

Comments
 (0)