Is `console.log()` reference redefiend by loglevel?
Doogiemuc opened this issue · 2 comments
Could it be that loglevel is (still) redefining the console.log function? (See #129)
I am redefining console.log in my own module. And after some time my method is not called anymore. I am not calling loglevel.setLevel(...)
as mentioned in the issue #129
My code:
this.logOrig = console.log
console.log = this.myOwnLogMethod
This works at the beginning. When some code calls console.log, then my call is used. But when I initialize loglevel
const log = require("loglevel").getLogger("liquido-api");
then myOwnLogMethod is not called anymore. Can I do something about that?
No - loglevel never redefines console.log
, it doesn't mutate the console object at all. The discussion in #129 is just talking about loglevel defining its own loglevel.debug
method.
There must be something else going on here. Can you put together a standalone demo reproducing the behaviour you're seeing?
Ok I learned a lot about bind(), apply() and call() in the last days. And that it is not a good idea to redefine console.log because you loose the stacktrace information in the browesers log .... nevermind.