Multiple Colors in the Same Console Line?

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:

As you can see, I like to use colours to highlight stuff in logs.

Any way to achieve this in Unreal? I’ve tried the html tag method, and it did not parse.

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…)

1 Like