-
-
Notifications
You must be signed in to change notification settings - Fork 158
Return log.debug → console.debug mapping #126
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
Comments
@kiyanovsky I don't think this is correct. I'm using Chrome 70, which I think is the latest, and with 'Default levels' selected in the console, I agree the current behaviour isn't perfect but I don't have a better alternative. The current implementation ensures that the visibility of It is awkward that Chrome behaves this way, but given the tradeoffs I still think it's the right choice. |
Hi Tim, I use Chrome 70 (screenshot). And console.debug gives you the debug (verbose) message: screenshot. Maybe you have debug messages turned off in the console, but it doesn't mean the console.debug doesn't work. Also, console.debug is documented (although, it doesn't behave as the documentation says). |
Is there a workaround so I can tell log level to use console.debug for log.debug? |
Yes, it's existed and been logged for a very long time, that's not the problem. The problem is that the recent default level filters hide verbose logs, so many users get confused. Example: Note that 'Default levels' is selected as the log filter, as it is by default. You must've changed this, but most users aren't aware it exists, which causes problems. If you really want to work around this for your case, you can write a plugin to do so. Docs are here: https://github.com/pimterry/loglevel#writing-plugins. I expect it'd be something like: let originalFactory = log.methodFactory;
log.methodFactory = function (methodName, logLevel, loggerName) {
if (methodName !== 'debug') {
return originalFactory(methodName, logLevel, loggerName);
} else {
return console.debug;
}
};
log.setLevel(log.getLevel()); // Be sure to call setLevel method in order to apply plugin (EDIT: Updated with typo fix mentioned below) This is a quick hack, and I haven't tested it, but it should be pretty close. Note that I've skipped the extra logic to handle console.debug not being available/needing to be bound/etc. If you're only worried about Chrome & modern browsers though you don't need that. If you want the full logic, you can follow it from https://github.com/pimterry/loglevel/blob/master/lib/loglevel.js#L92-L98, and copy across whatever bits you need. |
Thank you, Tim, the workaround works as expected! The only thing, you must be mistaken "method" for "methodName". |
Ah, yes, you're totally right 😄. Glad to hear that works for you! |
Hi,
In task #111, you decided to map log.debug to console.log. In the latest Chrome version,
Now, when you map debug to log, both debug and info levels are shown in info. It'd be helpful to see them in different sections as they are supposed to be.
Best regards,
Andrey.
The text was updated successfully, but these errors were encountered: