'Get Colorized spdlog output with qt_sinks

Ok so I hooked up the QTextEdit with spdlog. But how to get the colorized output from spdlog/fmt to show in the QTextEdit? Am I doomed to implement my own message handler for that to happen? Or is there a slicker way?



Solution 1:[1]

I saw the Qt Creator output pane can handle ASCII color codes. So I pulled this code from its source code and added extra functionality(bold, italic etc). After that I take QTextCursor* from QTextEdit or QPlainTextEdit objects and easily parse color codes and insert into thise widgets. In order to use this functionality you have to change spdlog's qt_sinks.h header with this.. After that use this helper class to see colored output in these widgets.

Example result: enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 M. Galib Uludag