Skip to content

specifying a logger does not work with pino@9.8+ #378

Description

@rhdhvolschenk

When upgrading pino up-to or beyond 9.8, a logger cannot be specified anymore.

import pino from "pino";
import pinoHTTP from "pino-http";

export const logger = pino(/* ... */);
export const logHTTP = pinoHTTP({ logger }); // <-- This breaks
No overload matches this call.
  Overload 1 of 2, '(opts?: Options<IncomingMessage, ServerResponse<IncomingMessage>, never> | undefined, stream?: DestinationStream | undefined): HttpLogger<...>', gave the following error.
    Type 'Logger<never, boolean>' is not assignable to type 'Logger<never, boolean> | undefined'.
      Type 'import("/projectpath/node_modules/pino/pino").Logger<never, boolean>' is not assignable to type 'import("/projectpath/node_modules/pino-http/node_modules/pino/pino").default.Logger<never, boolean>'.
        Type 'Logger<never, boolean>' is not assignable to type 'LoggerExtras<never, boolean>'.
          The types returned by 'child(...)' are incompatible between these types.
            Type 'import("/projectpath/node_modules/pino/pino").Logger<ChildCustomLevels, boolean>' is not assignable to type 'import("/projectpath/node_modules/pino-http/node_modules/pino/pino").default.Logger<ChildCustomLevels, boolean>'.
              Type 'Logger<ChildCustomLevels, boolean>' is not assignable to type 'LoggerExtras<ChildCustomLevels, boolean>'.
                Types of property 'onChild' are incompatible.
                  Type 'import("/projectpath/node_modules/pino/pino").OnChildCallback<ChildCustomLevels>' is not assignable to type 'OnChildCallback<ChildCustomLevels>'.
                    Types of parameters 'child' and 'child' are incompatible.
                      Type 'import("/projectpath/node_modules/pino-http/node_modules/pino/pino").default.Logger<ChildCustomLevels, boolean>' is not assignable to type 'import("/projectpath/node_modules/pino/pino").Logger<ChildCustomLevels, boolean>'.
                        Property 'msgPrefix' is missing in type 'BaseLogger & LoggerExtras<ChildCustomLevels, boolean> & { customLevels: { [level in ChildCustomLevels]: number; }; useOnlyCustomLevels: boolean; } & { [K in Exclude<...> | ... 4 more ... | Exclude<...>]: LogFn; } & { [level in ChildCustomLevels]: LogFn; }' but required in type 'BaseLogger'.
  Overload 2 of 2, '(stream?: DestinationStream | undefined): HttpLogger<IncomingMessage, ServerResponse<IncomingMessage>, never>', gave the following error.
    Object literal may only specify known properties, and 'logger' does not exist in type 'DestinationStream'.ts(2769)
pino.d.ts(224, 13): 'msgPrefix' is declared here.

If I were to hazard a guess, I would say it stems from this change. Here is a comment about the same issue in another project.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions