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

Method defaultErrorLog

lib/log-controller.js:81–89  ·  view source on GitHub ↗

* Logs an error handled by the default error handler. * Uses `error` for 5xx status codes, `info` for 4xx. * * @param {Error} error The error being handled. * @param {object} request Fastify request object. * @param {object} reply Fastify reply object (must have `s

(error, request, reply, metadata)

Source from the content-addressed store, hash-verified

79 * @param {object} [metadata] Extra contextual data (unused).
80 */
81 defaultErrorLog (error, request, reply, metadata) {
82 if (this.isLogDisabled(request)) { return }
83
84 if (reply.statusCode >= 500) {
85 reply.log.error({ req: request, res: reply, err: error }, error?.message)
86 } else {
87 reply.log.info({ res: reply, err: error }, error?.message)
88 }
89 }
90
91 /**
92 * Logs stream-level errors that occur after headers have been sent.

Callers 2

defaultErrorHandlerFunction · 0.80
logger.test.jsFile · 0.80

Calls 3

isLogDisabledMethod · 0.95
errorMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected