Skip to content

Commit

Permalink
Use seconds instead of ms to report request times
Browse files Browse the repository at this point in the history
  • Loading branch information
pastelsky committed Jun 6, 2021
1 parent 5fb566a commit 7572841
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/middlewares/requestLogger.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ async function requestLoggerMiddleware(ctx, next) {
return
}

const requestStart = now()
const requestStart = Date.now()
await next()
const requestEnd = now()
const requestEnd = Date.now()
const time = requestEnd - requestStart

logger.info(
Expand All @@ -30,9 +30,9 @@ async function requestLoggerMiddleware(ctx, next) {
status: ctx.response.status,
time,
},
`REQUEST: ${ctx.response.status}${time.toFixed(0)} ms ${ctx.req.method} ${
ctx.request.url
}`
`REQUEST: ${ctx.response.status}${(time / 1000).toFixed(2)}s ${
ctx.req.method
} ${ctx.request.url}`
)
}

Expand Down

0 comments on commit 7572841

Please sign in to comment.