abumq / easyloggingpp

C++ logging library. It is extremely powerful, extendable, light-weight, fast performing, thread and type safe and consists of many built-in features. It provides ability to write logs in your own customized format. It also provide support for logging your classes, third-party libraries, STL and third-party containers etc.
MIT License
3.75k stars 918 forks source link

Allow colored terminal output on Windows if ENABLE_VIRTUAL_TERMINAL_PROCESSING is set #843

Open chausner opened 11 months ago

chausner commented 11 months ago

This improves the compatibility of the LoggingFlag::ColoredTerminalOutput setting on Windows.

Windows 10 and later introduced virtual terminal support in conhost and Windows Terminal, see also https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences. This adds logic to easylogging++ to detect when virtual terminal processing is enabled, to allow colored output if LoggingFlag::ColoredTerminalOutput is set.

Before, easylogging++ would not attempt to output VT colored text even if the user enabled LoggingFlag::ColoredTerminalOutput and the terminal supports it.

With this change, running the all-logs sample in Windows Terminal:

image

This is a

I have

robloh commented 6 months ago

Thanks for this patch! Can confirm it works on Windows 10 with VS2019.

chausner commented 6 months ago

@abumq Any chance of getting this merged? :)