Skip to content

Colorizing output

goodsign edited this page Jul 22, 2013 · 2 revisions

Sometimes you may want to colorize your terminal output. Often this is done using CSI n [;k] m sequences.

Seelog formats are set using XML, so there is no way to use these sequences inside format identifiers. But there is a special format verb called 'EscM' that takes the 'n[;k]' part as the parameter. You can use it to perform graphical options customization for your terminal outputs.

Example

If you use such config:

<seelog>
    <outputs>
        <console formatid="colored"/>
    </outputs>
    <formats>
        <format id="colored"  format="%EscM(46)%Level%EscM(49) %Msg%n%EscM(0)"/>
    </formats>
</seelog>

and then log any message, the log level will have cyan background. 46 sets the background, 49 resets it.

Recommendations

  • Use %EscM(0) at the end of the message (as well as %n) to reset all graphical changes