MCPcopy Create free account
hub / github.com/fastify/fastify / requestCompleted

Method requestCompleted

lib/log-controller.js:62–70  ·  view source on GitHub ↗

* Logs the outcome of a completed request. * Uses `error` level when an error is present, `info` otherwise. * * @param {Error | null} error Error that occurred during the response, if any. * @param {object} request Fastify request object. * @param {object} reply Fastify r

(error, request, reply, metadata)

Source from the content-addressed store, hash-verified

60 * @param {object} [metadata] Extra contextual data (unused).
61 */
62 requestCompleted (error, request, reply, metadata) {
63 if (this.isLogDisabled(request)) { return }
64
65 if (error) {
66 reply.log.error({ res: reply, err: error, responseTime: reply.elapsedTime }, 'request errored')
67 } else {
68 reply.log.info({ res: reply, responseTime: reply.elapsedTime }, 'request completed')
69 }
70 }
71
72 /**
73 * Logs an error handled by the default error handler.

Callers 2

onResponseCallbackFunction · 0.80
logger.test.jsFile · 0.80

Calls 3

isLogDisabledMethod · 0.95
errorMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected