About color.h

2 views
Skip to first unread message

Gabriela Gibson

unread,
Sep 17, 2015, 9:03:30 AM9/17/15
to CorinthiaTeam
In another topic, Peter wrote:

On Wednesday, September 16, 2015 at 4:15:13 PM UTC+1, Peter Kelly wrote:

>
> There's quite a few colour macros used here, e.g.:
>
>
>     printf(CYAN "ODFParagraphContentGet\n" RESET);
>
>
> These colours could perhaps be integrated with Gabriela's logging framework, so they're not explicitly specified by filter code, and can be turned on/off or customised easily. We could perhaps have one colour per level, or alternatively an additional parameter to specify the colour. Gabriela - any thoughts on this?
>

color.h [1] can be turned off at compile time (gcc -DCOLOR=0), then it does nothing (it adds an empty string instead of the ANSI seq.) That said, colors should be off by default, will fix.

I will add something so people can setup colors for their log levels (the names themselves which are currently not colorised), in case the provided choice is no good for them (some folks are colourblind for example and want a different combination).

Currently logging works so: log_macro output is is split into 'information about where' (log level, file, function, line) and 'contents of information' both which are passed as (char*, char*) to whatever output function is currently selected. You can then use your output function to color the two strings via any of the printf functions.

G

[1] https://github.com/GabrielaBarbara/logger/blob/master/include/color.h

Gabriela Gibson

unread,
Sep 17, 2015, 9:08:36 AM9/17/15
to CorinthiaTeam
Note: if you 'leak' colour because you forgot a RESET, type 'stty sane' at your terminal prompt.

;-)

G

Reply all
Reply to author
Forward
0 new messages