* 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)
| 20 | * with child bindings added. |
| 21 | */ |
| 22 | function 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 | * |
no test coverage detected
searching dependent graphs…