Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: on not working (or at least not as expected or misleading documentation) #2109

Closed
nopeless opened this issue Apr 12, 2022 · 2 comments · Fixed by #2120
Closed

[Bug]: on not working (or at least not as expected or misleading documentation) #2109

nopeless opened this issue Apr 12, 2022 · 2 comments · Fixed by #2120

Comments

@nopeless
Copy link

🔎 Search Terms

on error

The problem

logger.on event callbacks are not fired

This example can be found in the README.md (.on("error"))

I read some of winston's code base and found out that Logger ultimately derives from streams, which are known to be event emitters. Perhaps .on("error") is not when a logger is called with an error, but when there is an internal stream error

Nonetheless, either the code is wrong or the documentation is misleading

What version of Winston presents the issue?

3.7.2

What version of Node are you using?

v16.13.1

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

No response

Minimum Working Example

import { default as winston } from "winston";

const logger = winston.createLogger({
    transports: [
      new winston.transports.Console({
        stderrLevels: [`error`],
      }),
    ],});

logger.on("error", err => {
  console.log("CALLBACK CALLED");
})

logger.error('what');

Additional information

No response

@wbt
Copy link
Contributor

wbt commented Apr 28, 2022

My understanding is that that callback was only for errors originating in the logger itself.
I opened a PR for your review; do you think it adequately addresses the issue?

@nopeless
Copy link
Author

@wbt yes you understood it correctly

thanks for addressing the issue

@wbt wbt closed this as completed in #2120 Apr 29, 2022
wbt added a commit that referenced this issue Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants