2015-04-20

The log comes in colors like a rainbow

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.

2015-04-10

Can you explain me

As I have written before, the 'company language' is English. This means the most used language is funny English since only a few of us has English as the mother tongue. I both write and speak funny English as I'm doing right now. Funny English is a language with many dialects. One grammar rule I think stems from central Europe (German,Flemish,Dutch) is to omit the introductory 'to' when you have a transitive with an indirect object. E.g. in proper English 'can you explain to me ...' becomes 'can you explain me ...'.
To me as a Swede omitting 'to' sounds weird, but it has become so common at the company I have heard native English speakers yield to this funny English grammar rule. I suppose this is one way languages evolve. I'll bet my 5 cent the introductory 'to'  will disappear in English in the next 100 years.