blakmatrix / colored

colorize your streams (also cli tool to colorize log files) - A great alternative to CCZE!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to use colored as a library?

abhas opened this issue · comments

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! 👍

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