Let’s have more colors

Are you a color lover? Then we have great news for you – we are interpreting ANSI escape codes to make your logging life more colorful! We do so by interpreting SGR parameters inside the event message body.

ANSI escape codes (their SGR subset in particular) are embedded in text to modify its appearance such as color, style, and weight. It works the same way as tags in HTML, except there is no nesting. The code starts with the escape character 0x1b (usually displayed as ^[) followed by [ (multi-byte escape code) and a list of color or formatting numbers delimited by a semicolon. The list is terminated with the m character.

For example, ^[[34;1;4m sets the text to blue (34), bold (1), and underlined (4).

Go ahead and give it a try. If you are using Python, check out the termcolor module, or term-ansicolor for Ruby, or AnsiColoring for Java.

Viliam is a co-founder and in a position that could be called CTO.

Posted in Feature, Web

Leave a Reply