Visitar URL original
Allow forcing the use of colors · Issue #922 · debug-js/debug · GitHub
Skip to content

Allow forcing the use of colors #922

Description

@svallory

Hi,

I'm developing a Figma plugin and the code runs on a sandbox with no access to window or process so although I'm using Chrome Dev Tools to see the messages, debug is not coloring them.

Also, I can't set environment variables, so I would like to useColor to true, like I'm using Debugger.enable('cva:*');

Activity

  1. svallory commented on Jan 7, 2023

    @svallory
    Author

    I was looking through the source code and it looks like the useColors IS exported. The problem is with the typings provided by @types/debug.

    I'm going to fork the project and convert it to Typescript so I can use what I need. Are you interested in a PR converting to TS?

    I can also PR just the correct typings and you can add it to the project.

  2. svallory commented on Jan 7, 2023

    @svallory
    Author

    In the mean time, for any Typescript coders, this can force debug to use colors:

    // This is necessary because the typings are out of date on Jan 7th, 2023
    // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
    (Debugger as any).useColors = () => true;
  3. webketje commented on Mar 24, 2023

    @webketje

    Related and may be of interest: https://github.com/metalsmith/metalsmith/blob/master/lib/debug.js

    This custom debugger based on debug-js (part of metalsmith.js) demonstrates how you can assign fixed colors per channel (eg :warn, :info etc) & pipe the output to a file (Debugger.handle = fileLogHandler('my.log'))

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