const test = Fastify({
childLoggerFactory(logger, bindings, opts, rawReq) {
// Calculate additional bindings from the request if needed
bindings.traceContext = rawReq.headers["x-cloud-trace-context"]
return logger.child(bindings, opts)
},
})
However, it produces the following type error:
No overload matches this call.
The last overload gave the following error.
Object literal may only specify known properties, and 'childLoggerFactory' does not exist in type 'FastifyHttpOptions<Server<typeof IncomingMessage, typeof ServerResponse>, FastifyBaseLogger>'.ts(2769)
Link to code that reproduces the bug
No response
Expected Behavior
The types should define the childLoggerFactory option and there should be no type error
Prerequisites
Fastify version
4.26.2
Plugin version
No response
Node.js version
v22.0.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
Sonoma 14.6.1
Description
The example given in https://fastify.dev/docs/latest/Reference/Server/#setchildloggerfactory makes it seem like the following typescript should work:
However, it produces the following type error:
Link to code that reproduces the bug
No response
Expected Behavior
The types should define the childLoggerFactory option and there should be no type error