Skip to content
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

Debug level is not showing in console #111

Closed
asasine opened this issue Aug 7, 2017 · 9 comments
Closed

Debug level is not showing in console #111

asasine opened this issue Aug 7, 2017 · 9 comments

Comments

@asasine
Copy link

asasine commented Aug 7, 2017

As the title states, calls to log.debug do not print results to the console. The following script index.js was run with node index.js:

var log = require('loglevel');

log.setLevel(log.levels.TRACE);

log.error('error');
log.warn('warn')
log.info('info');
log.debug('debug');
log.trace('trace');

and the following was displayed on the console:

error
warn
info
Trace: trace
    at Object.<anonymous> (/some/random/directory/index.js:9:5)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3

As the output shows, the DEBUG level is skipped.

I am using loglevel v1.4.1 with Node.js 8.2.1 and npm 5.3.0 on macOS 10.12.6.

@pimterry
Copy link
Owner

pimterry commented Aug 8, 2017

Yes, this is currently being discussed over here: #64 (comment). V8 seems to have quietly made console.debug do nothing, which breaks this. The current plan is to just map log.debug to console.log in future - would that work for you?

@asasine
Copy link
Author

asasine commented Aug 8, 2017

Yes this would work for my needs. In the future of this package, I share the sentiment of @olegstepura that there should exist all 6 logging levels as log.fatal would be useful to me for remote logging and alerting purposes.

@kutuluk
Copy link
Contributor

kutuluk commented Aug 11, 2017

debug

@nicocrm
Copy link

nicocrm commented Sep 3, 2017

+1 for mapping to console.log.... it's annoying not having a debug log level. Any plan for updating that soon?

pimterry added a commit that referenced this issue Sep 11, 2017
Chrome now no longer prints console.debug messages, and they're now a
noop. This change transparently maps all debug logging to console.log,
which ensures messages do appear, without breaking the API or typically
making any noticable changes in usage at all.

Connects-To: #64
Connects-To: #111
@pimterry
Copy link
Owner

This should now be fixed, released in 1.5.0.

log.debug now uses console.log under the hood, so will work in Chrome versions that make console.debug a noop. Thanks for the report, let me know if you have any further trouble!

@Trikolon
Copy link

I don't understand why this change is required for Chrome. The latest stable version of Chrome shows console.debug statements if you enable all log levels in the console as shown by @kutuluk . Am I missing something here?

@pimterry
Copy link
Owner

@Trikolon not having these messages appear by default is somewhat annoying and confusing for loglevel users, and the MDN docs say:

Console.debug()
An alias for log() - starting with Chromium 58 this method is a no-op on Chromium browsers.

In addition, it's no longer listed in the Node docs for console at all: https://nodejs.org/api/console.html

You're right that you can change the log levels as an effective a workaround. At the moment though it looks like console.debug is being steadily killed off, there's zero downside I can see to using console.log under the hood instead, and it makes loglevel work more intuitively for Chrome users right now.

@Trikolon
Copy link

That makes sense. Thanks for the explanation!

@MichelSimonot
Copy link

MichelSimonot commented Aug 17, 2018

@pimterry It's much more annoying to have them logged at the wrong level.

The MDN docs have probably been updated since you quoted them, but console.debug is not a noop.

screen shot 2018-08-17 at 9 56 53 am

Please don't try to fix a "problem" that isn't yours by changing expected behaviour.

Edit: I may have jumped-the-gun with this comment, but it is still very misleading to not support console.debug in environments where it does have distinctive behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants