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

Allow forcing the use of colors #922

Open
svallory opened this issue Jan 7, 2023 · 3 comments
Open

Allow forcing the use of colors #922

svallory opened this issue Jan 7, 2023 · 3 comments

Comments

@svallory
Copy link

svallory commented Jan 7, 2023

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:*');

@svallory
Copy link
Author

svallory commented Jan 7, 2023

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.

@svallory
Copy link
Author

svallory commented Jan 7, 2023

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;

@webketje
Copy link

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
Labels
None yet
Development

No branches or pull requests

2 participants