Skip to content

[Bug]: Logger is required for profiler#2432

Description

@MarkMurphy

馃攷 Search Terms

Logger is required for profiler

The problem

Upgraded Winston to 3.12.0 and my tests started failing with an error coming from Winston: "Error: Logger is required for profiler"

I have a process that calls logger.startTimer(), where logger is a child logger of another created via the createLogger method.

This code seems to be the source of the error:

if (typeof logger !== 'object' || Array.isArray(logger) || !(logger instanceof Logger)) {

My child logger instance's class is DerivedLogger, performing the same checks as the code above I get:

console.log(
  typeof logger !== 'object',
  Array.isArray(logger),
  !(logger instanceof Logger),
)

Produces false, false, false

console.log(typeof logger, require('util').inspect(logger))

Produces object, DerivedLogger {}

I believe this was introduced via #2226

What version of Winston presents the issue?

v3.12.0

What version of Node are you using?

v20.11.1

If this worked in a previous version of Winston, which was it?

No response

Minimum Working Example

No response

Additional information

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