Bug: Instantiating logger breaks console.error()
See original GitHub issueDescribe the bug
We are using tslog inside Blitz.js. It’s really great, but noticed that it’s causing a regression because it breaks the default behavior of console.error
.
Before instantiating a tslog logger, console.error(new Error("Hello"))
prints the following:
Error: Hello
at Test (webpack-internal:///./pages/ssr.tsx:92:17)
...redacted
But after instantiating a logger, console.error(new Error("Hello"))
prints this:
[Error: Hello]
As you can see, this is very bad because you can’t tell where the error is from.
In this case, third-party code is using console.error
, so it’s not something we can change.
To Reproduce Steps to reproduce the behavior:
- Run
console.error(new Error("Hello"))
- See error with stack trace
- Instantiate logger:
new Logger()
- Run
console.error(new Error("Hello"))
- See there is no stack trace.
Node.js Version Node v12
OS incl. Version
System:
OS: macOS 10.15.7
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Memory: 5.43 GB / 64.00 GB
Shell: 3.1.2 - /usr/local/bin/fish
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Bug in console.log? [duplicate] - javascript - Stack Overflow
console.log() prints a reference to the object with as "> Object" when the code is executed · The state of the object when...
Read more >The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, consult this list of the 10 most common JavaScript issues from a...
Read more >Warnings are too "loud", mislabeled and make console difficult ...
My goal is to stop this effectively "breaking" the error console, i.e. making it unusable by flooding it with messages. Possible approaches:.
Read more >Logging Cookbook — Python 3.11.1 documentation
This class is designed to look like a Logger , so that you can call debug() , info() , warning() , error() ,...
Read more >{solved} console.log() bug problems - Codecademy
console. log() is a function, it will log/print on the console/screen the message you put in the ( ) . console. log() is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sweet, thanks! Will test this in Blitz.
Thank you very much, that was really helpful! I have found and fixed the issue. Just need to update the tests to remain at 100% coverage. Expect an update today or at the latest tomorrow.