Skip to content

Request: throw if partial logger is passed in #4510

@cjihrig

Description

@cjihrig

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

It is possible to pass an existing logger object to the fastify() function. There is a check here that detects if the logger instance is valid.

If a partial logger is passed in, it is currently ignored because that isValidLogger() function returns false. If I pass in an incorrect logger object, it would be more helpful to know that it was rejected rather than silently ignored. I propose throwing if a partially matching logger is provided.

Motivation

I spent a few hours debugging why my logger was not being used. It turns out that pino's child() function is not enumerable, and @fastify/deepmerge only clones enumerable properties. I created a fastify server with the cloned logger, and it was silently ignored because child() was missing.

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions