The log of the data warehouse ETL engine has been black and white up until now. Some years ago I added colors to the log. However the same text string printed to console was also written to the archive log where the color attributes looked awful. But a few weeks ago while jogging an early morning I got the idea of filter out all attributes with a regular expression.
This is the original code writing the console log message to the archive log
fwrite($this->logHandle, "$lmsg");
|
This regular expression sifts out all color attributes:
fwrite($this->logHandle, preg_replace('/\033\[[\d;]+m/', '',"$lmsg"));
|
Simple as that:)
This is a black and white example of the console log:
And this is the color version:
This is not the most useful hack I have done and it isn't exactly a rainbow, but the console log is easier to read.
No comments:
Post a Comment