Skip to content

Commit

Permalink
Add request time in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
janicduplessis committed May 7, 2024
1 parent 2c3f939 commit 29b3093
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 29b3093

Please sign in to comment.