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

Use console.debug() instead of console.log() where available (e.g. browsers) #600

Closed
Qix- opened this issue Sep 11, 2018 · 12 comments
Closed
Assignees
Labels
change-minor This proposes or provides a change that requires a minor release discussion This issue is requesting comments and discussion feature This proposes or provides a feature or enhancement
Milestone

Comments

@Qix-
Copy link
Member

Qix- commented Sep 11, 2018

Currently debug output in the browser gets console.log()'d.

However, browsers have a console.debug() call (nonexistent in Node.js, of course) that would group all debug output into its own category, perhaps making it easier for debugging in the browser when trying to look at regular application output.

Relevant lines:

https://github.com/visionmedia/debug/blob/master/src/browser.js#L112-L114

Thoughts?

@Qix- Qix- added discussion This issue is requesting comments and discussion feature This proposes or provides a feature or enhancement change-minor This proposes or provides a change that requires a minor release labels Sep 11, 2018
@Qix- Qix- self-assigned this Sep 11, 2018
@Qix-
Copy link
Member Author

Qix- commented Oct 31, 2018

@picwellwisher12pk that has absolutely nothing to do with this ticket. Please open a new one.

@nmccready
Copy link

nmccready commented Nov 19, 2018

I doubt this will ever happen. The if you want to extend you're console or logger then that is the entire purpose of this library.

https://github.com/nmccready/preacher

You're asking this library to do too much. Keep it the way it is unixy.

@Qix-
Copy link
Member Author

Qix- commented Nov 20, 2018

@nmccready I don't see how your response is relevant at all. We're already using console.log() everywhere. I'm simply suggesting the use of console.debug() in the browser instead, since it's available there and would allow people to better filter out log messages using inspector tools.

Since I'm not getting much intelligible feedback on this, I don't see any objections and I think it's an improvement to better match how the behavior works in the console.

@nmccready
Copy link

10-4, sorry I thought you were asking to override console.debug with debug itself. Instead your asking for the implementation of debug to use console.debug and not console.log for its output. Apologies

@targos
Copy link

targos commented Nov 24, 2018

console.debug() is available in Node from version 8, and would also be filterable with inspector tools if node is run with --inspect.

@Qix-
Copy link
Member Author

Qix- commented Nov 24, 2018

@targos TIL. Yeah I figured the logic would be (console.debug || console.log)(...).

@Qix- Qix- added this to the 5.x milestone Dec 18, 2018
@Qix-
Copy link
Member Author

Qix- commented Dec 19, 2018

Actually, the node version uses stdout. If people want to use console.debug, they should see #556.

Qix- added a commit that referenced this issue Dec 19, 2018
also removes a branch for each logging call, slightly improving
performance in the browser.
Qix- added a commit that referenced this issue Dec 19, 2018
also removes a branch for each logging call, slightly improving
performance in the browser.
Qix- added a commit that referenced this issue Dec 19, 2018
also removes a branch for each logging call, slightly improving
performance in the browser.
@Qix- Qix- closed this as completed in #659 Dec 19, 2018
Qix- added a commit that referenced this issue Dec 19, 2018
also removes a branch for each logging call, slightly improving
performance in the browser.
@danielweck
Copy link

Just a heads-up about this code change: by default the Chromium web console (maybe others too) filters messages at the info level which excludes console.debug(), so developers will have to explicitly activate the verbose level to see messages outputed by debug() in versions >4.1.0. I have just verified this new behaviour in an Electron app using the debug() code from the master branch (instead of the officially-release version 4.1.0).
https://developers.google.com/web/tools/chrome-devtools/console/
This is a minor breaking change, but as long as it is well-documented, this should not cause debug() users too many headaches, right? :)

@Qix-
Copy link
Member Author

Qix- commented Dec 21, 2018

Seeing as how that's kind of how terminal applications work currently, this is fine. I was aware of this behavior when making the change, hence why it's marked for the 5.x release.

@PieerePi
Copy link

Frankly speaking, it's not a good idea. When I upgraded the package from 4.1.1 to 4.2.0, I couldn't find my debug logs until I switched to the 'user messages' category.

It's not user friendly, although that chould be Chrome's problem.

@Qix-
Copy link
Member Author

Qix- commented Nov 19, 2020

@PieerePi That is definitely chrome's problem, not ours. This library isn't built for only chrome.


Locking this as I don't think there's much more discussion to be had here.

@debug-js debug-js locked as resolved and limited conversation to collaborators Nov 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
change-minor This proposes or provides a change that requires a minor release discussion This issue is requesting comments and discussion feature This proposes or provides a feature or enhancement
Development

No branches or pull requests

7 participants
@nmccready @danielweck @Qix- @targos @PieerePi and others