On 10/28/20 12:51 AM, Thomas Huth wrote: >>>> +#define GREEN(txt) ( \ >>>> + "\033[0;92m" txt \ >>>> + "\033[0m" \ >>>> +) >>> >>> I don't think this is very portable - and it will only make logs ugly to >>> read in text editors. Could you please simply drop these macros? >>>
> Sure, colored output is nice, but we certainly also need a way to disable > it, e.g. if you want to collect the log in a file and then have a look at it > in a text editor. Agreed. GNU libtextstyle (https://www.gnu.org/software/gettext/libtextstyle/manual/libtextstyle.html) is a much more portable way to do colored output where it becomes easy to enable/disable or even adjust the colors to user preferences. Sadly, it is GPLv3+, and thus unusable for qemu. But the bare minimum that you must have when making colored output gated on whether stdout is a terminal (that is, any program that does color should have a --color=off|auto|on command-line option, and that in turn implies function calls rather than macros to properly encapsulate the decision logic. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org