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 3.0.x messes colors in WebStorm? #493

Closed
gornostali opened this issue Aug 29, 2017 · 9 comments
Closed

debug 3.0.x messes colors in WebStorm? #493

gornostali opened this issue Aug 29, 2017 · 9 comments

Comments

@gornostali
Copy link

Hi everyone,

I'm working in WebStorm and have been enjoying debug colors for a good while. However, after an update from debug@v2.6.x to debug@v3.0.x all of the colors are gone being replaced by a straight red.

Downgrading back to debug@v2.6.x - colors are back.

Please refer to attached image. Sequelize uses debug@latest and entries are shown in red, perhaps they used to be colored before update.

app-user:scripts: are my entries written with debug@v2.6.x. Change I debug to v3.0.x, they are turned red.

Any thoughts?

debug-3 0 x

@Qix-
Copy link
Member

Qix- commented Aug 29, 2017

@TooTallNate did debug v3 change to outputting to stderr? That's my first guess.

@thebigredgeek
Copy link
Contributor

https://github.com/visionmedia/debug/blob/master/src/node.js#L126 < yup. You can override:

const debug = require('debug');
debug.log = console.log.bind(console);

@Qix-
Copy link
Member

Qix- commented Sep 5, 2017

Yeah :/ IMO Webstorm should just be issuing \x1b[31m at the beginning of lines and allowing the program to output its own colors (i.e. by allowing the program to issue \x1b[0m directly before it if it doesn't want the red coloring).

Common case of IDE's trying to be smarter than the applications (note to IDE developers: don't do this - it never works well).

You're welcome to open a ticket with WebStorm or override the output like @thebigredgeek suggests (though I don't recommend doing this at all) - however there's nothing we can really do on our end.

Sorry about this :/

@thebigredgeek
Copy link
Contributor

To be clear, you can parse the output text before passing to console.log if you override debug.log, so really you can fix this however you'd like in application code

@TooTallNate
Copy link
Contributor

Closing since there's nothing actionable on our end for this one.

@segrey
Copy link

segrey commented Sep 29, 2017

Hi,
Indeed, WebStorm doesn't support stderr coloring at the moment (https://youtrack.jetbrains.com/issue/IDEA-137769). It's not an easy fix, because it will lead to API breakage. But it is on my list. Meanwhile, why is it impossible to configure output stream for debug package, like before: DEBUG_FD=1?

@Qix-
Copy link
Member

Qix- commented Sep 29, 2017

@segrey Thanks for handling it!

Configuring output streams isn't common in unix environments. debug would be the first package I've ever seen that allows you to select which file descriptor you want to output on. Usually you let the shell redirect descriptors.

@segrey
Copy link

segrey commented Sep 29, 2017

Agree, configuring output stream isn't common, but it was working like this before :). Alright, will try to fix it on WebStorm's side.

@skn3
Copy link

skn3 commented Oct 18, 2017

for anyone looking for a quick fix, as mentioned above you can bind to the console. Remember to do it like so:

require('debug').log = console.log.bind(console);

and not:

require('debug')('namespace').log = console.log.bind(console);

the latter will only bind log for the particular namespace!

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

No branches or pull requests

6 participants