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

strip colors #1

Closed
metamindxx opened this issue Nov 17, 2010 · 3 comments
Closed

strip colors #1

metamindxx opened this issue Nov 17, 2010 · 3 comments

Comments

@metamindxx
Copy link

Great module.

Is there a way to strip the color formatting from a string. I set the color in the code depending on the context and send it to the logger. The logger sends it to the console and also to a log file. I am getting things like "�[39m�[22m" appearing in my log file. I would like to strip the color information before it gets logged to file.

Thanks.

@Marak
Copy link
Owner

Marak commented Nov 17, 2010

Hrmmm, I'm not really sure of the best approach. You could strip the escape codes back out, but there is probably a more elegant solution if you implement a new logging class.

What would the API look like for this?

@metamindxx
Copy link
Author

I was just thinking of having something like:

console.log(str) // includes control chars

and f.write(str.plain) // just writes the plain string ( or maybe str.s for brevity)

@Marak
Copy link
Owner

Marak commented Apr 15, 2011

I think tty detection might be the best way to go for this. That way, if the TTY isn't available it won't use the unicode values.

@Marak Marak closed this as completed in 5af04df Jul 18, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants