MCPcopy
hub / github.com/fastify/fastify / createChildLogger

Function createChildLogger

lib/logger-factory.js:22–34  ·  view source on GitHub ↗

* Utility for creating a child logger with the appropriate bindings, logger factory * and validation. * @param {object} context * @param {import('../fastify').FastifyBaseLogger} logger * @param {import('../fastify').RawRequestDefaultExpression } req * @param {string} reqId * @param {import

(context, logger, req, reqId, loggerOpts)

Source from the content-addressed store, hash-verified

20 * with child bindings added.
21 */
22function createChildLogger (context, logger, req, reqId, loggerOpts) {
23 const loggerBindings = {
24 [context.requestIdLogLabel]: reqId
25 }
26 const child = context.childLoggerFactory.call(context.server, logger, loggerBindings, loggerOpts || {}, req)
27
28 // Optimization: bypass validation if the factory is our own default factory
29 if (context.childLoggerFactory !== defaultChildLoggerFactory) {
30 validateLogger(child, true) // throw if the child is not a valid logger
31 }
32
33 return child
34}
35
36/** Default factory to create child logger instance
37 *

Callers 6

onBadUrlFunction · 0.85
onMaxParamLengthFunction · 0.85
createRouteEventHandlerFunction · 0.85
fourOhFourFallBackFunction · 0.85
routeHandlerFunction · 0.85

Calls 1

validateLoggerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…