Skip to content

debug 3.0.x messes colors in WebStorm? #493

Description

@gornostali

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

Activity

  1. Qix- commented on Aug 29, 2017

    @Qix-
    Member

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

  2. thebigredgeek commented on Sep 4, 2017

    @thebigredgeek
    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);
  3. Qix- commented on Sep 5, 2017

    @Qix-
    Member

    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 :/

  4. thebigredgeek commented on Sep 5, 2017

    @thebigredgeek
    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

  5. TooTallNate commented on Sep 23, 2017

    @TooTallNate
    Contributor

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

  6. segrey commented on Sep 29, 2017

    @segrey

    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?

  7. Qix- commented on Sep 29, 2017

    @Qix-
    Member

    @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.

  8. segrey commented on Sep 29, 2017

    @segrey

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

  9. skn3 commented on Oct 18, 2017

    @skn3

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions