Skip to content

Commit

Permalink
fix: make childLoggerFactory use FastifyBaseLogger
Browse files Browse the repository at this point in the history
Fixes #4960
  • Loading branch information
flakey5 committed Dec 28, 2023
1 parent 8c0140a commit b7ed34c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions test/types/instance.test-d.ts
Expand Up @@ -16,6 +16,7 @@ import { DefaultRoute } from '../../types/route'
import { FastifySchemaControllerOptions, FastifySchemaCompiler, FastifySerializerCompiler } from '../../types/schema'
import { AddressInfo } from 'net'
import { Bindings, ChildLoggerOptions } from '../../types/logger'
import pino from 'pino'

const server = fastify()

Expand Down Expand Up @@ -312,6 +313,8 @@ function childLoggerFactory (this: FastifyInstance, logger: FastifyBaseLogger, b
server.setChildLoggerFactory(childLoggerFactory)
server.setChildLoggerFactory(server.childLoggerFactory)

expectAssignable<FastifyInstance>(fastify({ logger: pino() as FastifyBaseLogger }))

type InitialConfig = Readonly<{
connectionTimeout?: number,
keepAliveTimeout?: number,
Expand Down
2 changes: 1 addition & 1 deletion types/instance.d.ts
Expand Up @@ -488,7 +488,7 @@ export interface FastifyInstance<
* which allows for modifying or adding child logger bindings and logger options, or
* returning a completely custom child logger implementation.
*/
childLoggerFactory: FastifyChildLoggerFactory<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
childLoggerFactory: FastifyChildLoggerFactory<RawServer, RawRequest, RawReply, FastifyBaseLogger, TypeProvider>;

/**
* Hook function that is called when creating a child logger instance for each request
Expand Down

0 comments on commit b7ed34c

Please sign in to comment.