Skip to content

Commit

Permalink
Merge pull request #41709 from janicduplessis/@janic/request-time
Browse files Browse the repository at this point in the history
Add request time in logs
  • Loading branch information
roryabraham authored May 7, 2024
2 parents 5259776 + 29b3093 commit 0d2fa9e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libs/Middleware/Logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ function logRequestDetails(message: string, request: Request, response?: Respons
}

const Logging: Middleware = (response, request) => {
const startTime = Date.now();
logRequestDetails('Making API request', request);
return response
.then((data) => {
logRequestDetails('Finished API request', request, data);
logRequestDetails(`Finished API request in ${Date.now() - startTime}ms`, request, data);
return data;
})
.catch((error) => {
Expand Down

0 comments on commit 0d2fa9e

Please sign in to comment.