So, when priting debug messages into the console, its easy enough to change their color based on their verbosity. However, this changes the color of the entire text line.
This is, for example, another platform that does allow to change color of console output. This one works by using the classing html <color=#A3FF39> tags:
AFAIK you can’t do this with Unreal without engine modification. The best you can do is custom log colors. Here’s the macro that I’m using in my plugin.
/** A custom UE_LOG macro that outputs a colorized text message to the console. */
#define COLORIZED_LOG(Category, Verbosity, Color, Format, ...) \
{ \
bool bColorizeOutput = PLATFORM_SUPPORTS_COLORIZED_OUTPUT_DEVICE && ELogVerbosity::Verbosity >= ELogVerbosity::Display; \
if (bColorizeOutput) SET_WARN_COLOR(Color); \
UE_LOG(Category, Verbosity, Format, ##__VA_ARGS__); \
if (bColorizeOutput) CLEAR_WARN_COLOR(); \
}
The OutputDeviceColor namespace contains valid colors (e.g. COLOR_CYAN, COLOR_DARK_GREEN, etc…)
Hi! Sorry for necro-posting, may I ask you if this is still working for you?
I’ve tried to make this work for about half an hour but the text color doesn’t change…
Works fine on my end. Keep in mind this works only in the separate log window when starting the game with -LOG. It’s not going to work inside the editor’s log window.
This explains a lot, the Windows terminal also supports ANSI escape sequences so there’s no need to use a custom function for that, unfortunately I needed it in the editor or in Rider but it looks like I’d have to stick with red and yellow