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

Is it possible to use colored as a library? #2

Open
abhas opened this issue Apr 26, 2013 · 1 comment
Open

Is it possible to use colored as a library? #2

abhas opened this issue Apr 26, 2013 · 1 comment

Comments

@abhas
Copy link

abhas commented Apr 26, 2013

I'm new to nodejs and was testing out a SMTP server called Haraka. I wanted to see if I could use colored as a library so that I could colorize logs printed out by Haraka into color by default. That way one would not need to pipe the logs to colored.

Is this possible? Thanks for the tool! 👍

@blakmatrix
Copy link
Owner

It's possible, if you take a look at the binary https://github.com/blakmatrix/colored/blob/master/bin/colored.js you can see the way I instantiated it. colored(inputReadableStream, outputWriteableStream, options) You'd basically have to use that same code to utilize the default functionality.

I had plans to make it easier to use programmatically but up until now now one has indicated they wanted it. I also figured it was a bit of a silly idea as if one was colorizing their output they could probably do it in such a fine tune they wouldn't need a general colorizer, however, seeing this I went ahead and started designing it so that one could directly identify specific words/phrases. From here I had planned to also try and find a way to make a word/regex configurable so most of the code in https://github.com/blakmatrix/colored/blob/master/lib/colorize.js isnt even needed, but I never got around to it. The tool fit my need and out-preformed CCZE which was my goal.

Keep me updated on what you do, I'd be glad to help try and make the tool better :)

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