Skip to content

Commit

Permalink
Add response length to logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy-Gonzalez committed Dec 29, 2024
1 parent c6652fe commit c530b44
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ app.use(corsSelector);

// Enable request output when not a test
if (!Config.TEST) {
// Adds user id as "id" so we can log it with requests
morgan.token("id", function (req, _res) {
return tryGetAuthenticatedUser(req)?.id || "unauthenticated";
});
app.use(morgan(":status :method :url :id :response-time ms"));
app.use(morgan(":status :method :url :id :response-time ms :res[content-length] bytes"));
}

// Automatically convert requests from json
Expand Down

0 comments on commit c530b44

Please sign in to comment.