-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Winston logger] Filename displayed in stdout when using Winston logger is wrong #8790
Comments
Right now we make an assumption that you want to know which line directly triggered the logging. It might make sense to walk up the stack until we're out of |
thanks for your quick response @SimenB , i wanted to provide some more context around the issue:
|
One suggestion if we are not able to fix above issue is to have a jest flag (e.g. --shortConsoleOutput or something similar) that only outputs the message value - not the Filename:Linenumber or log type. This flag can be useful when someone is using Winston logger. This doesn't solve the issue listed above, but at least prevents the output of redundant data (same console.js and line number getting printed). Please let me know your opinion - if it makes sense then i can investigate more and come up with a PR. |
I'm not excited about We could have something like |
Any update / workaround on this? |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
[Winston logger] Filename and linenumber displayed in stdout when using Winston logger is wrong
(node_modules/winston/lib/winston/transports/console.js:79 is displayed instead of filename:line_number where the winston logger is called. e.g. tests/index2.test.js:7)
To Reproduce
Steps to reproduce the behavior:
NOTES: The behavior is correct when using console logging but incorrect when using winston logging. I noticed that there is snapshot test - which also exhibits this incorrect behavior (added as part of https://github.com/facebook/jest/pull/8021/files).
Also, it appears that the issue only happens when we use winston with jest. Winston by itself when used with node works well. I think there is some issue with jest-console package when we use Winston e.g. below code: https://github.com/facebook/jest/blob/e740de246b3a5ef4a7692f2f58bf8223323e4daf/packages/jest-console/src/getConsoleOutput.ts#L18
Seems to return
console.log node_modules/winston/lib/winston/transports/console.js:79
always whenever winston is used (it works as expected when using console logging)Actual behavior
Wrong filename and line number is displayed
console.log node_modules/winston/lib/winston/transports/console.js:79
Expected behavior
Exact filename and line number where logger is called is displayed e.g.
console.log tests/index2.test.js:15
` ● Console
Link to repl or repo (highly encouraged)
GitHub repo for Winston logging issue
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: