Closed KonradHoeffner closed 5 years ago
Can you put together a standalone reproduction so I can see this in action? It'd also be useful if you could be more specific about which browser you're using when you see this - a https://www.whatsmybrowser.org/ link would be perfect.
For now, using just the code above I can't seem to reproduce this. Skimming the code, the only time that calling log.debug
would ever change the definition of log.debug
is if console
wasn't defined initially. That's designed to handle issues in IE (either old IE, or newer IE with compatibility modes set badly), and if you're not using IE I don't think this should ever happen.
One way you could see this effect is if you're calling setLevel
between the two checks. Calling setLevel
does redefine every log method, either creating it afresh or replacing it with a no-op, depending on the level selected.
The browser is Firefox 67, the link is www.whatsmybrowser.org/b/S9N79PS. We do indeed use setLevel, I will investigate whether this solves the problem.
Yes, setLevel was indeed the problem, that solved it, thanks!
Great to hear, glad I could help! :+1:
We want to encapsulate log.debug with additional functionality, but for the reference seems to change, which breaks our code:
Is this intended functionality and a wrong assumption to make that the reference stays the same? Or must there be some other issue in our code?
We are using loglevel 1.6.1 in the browser.