Closed yesparthasarathy closed 3 years ago
This isn't really something that's up to loglevel - it depends how your application works and builds itself.
The easiest option would be to run something like window.loglevel = loglevel
in your code from a place where it is that you do have access to loglevel. That will explicitly make it globally available, so you can just run loglevel.whatever
from your browser console.
Alternatively, if you can access your bundler's require
equivalent dynamically, you might be able to run require('loglevel')
in your console to access it without making any code changes. You might need to look into the docs for the specific bundling tool you're using, or talk to those developers, to ask about how to dynamically require modules at runtime so you can do this (but this might not be possible). webpack-runtime-require apparently does this for webpack, but I've never tried it myself.
Unfortunately all of this depends on what bundler you're using, and applies to all libraries you use, it's nothing to do with loglevel specifically. I'm going to close this for now, since it's not really a loglevel issue, but let me know if there's anything else I can do to help.
But if we can just change the loglevel value in Local Storage and make the loglevel work after that then it will be a better solution.
BTW, the following words in readme is a bit confusing: "then run log.setLevel("trace") in your console to turn it all back on for a furious debugging session." These words had made me thought I could change the loglevel at run time for browser.
Then I found this issue and realize I still need the old trick of window.loglevel = loglevel
in my code first.
We are using the log-level in angular application. we would like to set the loglevel dynamically in the console (Developer console, so that we can see the debug information on the fly). we don't know how to get the instance of the root logger in the developer console.