Skip to content

New logger API #4624

@Eomm

Description

@Eomm

As a breaking change, we can simplify the input by splitting the logger option into multiple and dedicated properties:


After writing my comments around a simplification suggestion around the validateLogger function I have determined that we need to re-think how we deal with this issue.

It was a mistake (that I am responsible for) to accept either an object of options or an instance for the logger property. It's a simpler UX, but basically impossible to handle in a concise and maintainable way with the new throwing requirement. I think it is a good idea to introduce the throwing requirement. But I think it means we need to:

  1. Deprecate support for { logger: <logger_instance> }.
  2. Introduce { loggerInstance: <logger_instance> }.
  3. If loggerInstance is provided, it takes precedence over { logger: <options> }.

The other avenue is to deprecate { logger: <options> }, but I am quite certain that more people pass in options than they do logger instances. We'd break many more people with this avenue.

Originally posted by @jsumners in #4520 (review)

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersv5.xIssue or pr related to Fastify v5

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions