Skip to content

Commit

Permalink
Add duration for request logs
Browse files Browse the repository at this point in the history
  • Loading branch information
renatodellosso committed Feb 1, 2025
1 parent ad344f4 commit a3db7b7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ app.prepare().then(() => {
req: IncomingMessage,
res: ServerResponse<IncomingMessage>,
) {
const start = Date.now();
console.log(`IN: ${req.method} ${req.url}`);
if (!req.url) return;

const parsedUrl = parse(req.url, true);
handle(req, res, parsedUrl).then(() =>
console.log(`OUT: ${req.method} ${req.url} ${res.statusCode}`),
console.log(`OUT: ${req.method} ${req.url} ${res.statusCode} in ${Date.now() - start}ms`),
);
}

Expand Down

0 comments on commit a3db7b7

Please sign in to comment.