x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Change Color of Log Text

I'm trying to easily see my own log messages in the output log when I run my game. While the category helps it would be much better if I could visually instantly see my logs via a color. Now I know you can use Warning or Error as the Verbosity but while hunting through the code I spotted that the Verbosity has a value of SetColor... I just have no idea how to use it, I spent a good few hours diving through code but got lost :)

Basically I'd like to set it to a color so that my logs stand out against any real warnings, errors, or system logs that are automatically generated.

Product Version: Not Selected
Tags:
more ▼

asked Apr 18 '15 at 03:04 PM in C++ Programming

avatar image

ArcainOne
489 32 25 57

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Which log are you talking about, onscreen messages, or UED log interface.

For on screen messages, the third parameter lets you set a color

 GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("%s %s: %s"), NETMODE_WORLD, CLASS_FUNC_NAME,  *Msg));

for log interface

 SET_WARN_COLOR( COLOR_CYAN );
 FString Msg = FString::Printf(TEXT(Format), ##__VA_ARGS__ ); 
 UE_LOG( LogFF, Log, TEXT("%s%s() : %s"), NETMODE_WORLD, CLASS_FUNC_NAME, *Msg);
more ▼

answered May 06 '15 at 11:22 AM

avatar image

GeekyPayback
55 6 9 10

avatar image ArcainOne May 06 '15 at 03:47 PM

Hi GeekyPayback, Thank you for responding. I am specifically intrested in the Unreal Editor log. So SET_WARN_COLOR can change the color, but does it do that for all warnings or just the ones where the warn color is set?

Again thanks for the reply!

avatar image ArcainOne May 07 '15 at 05:01 AM

Okay I kind of see what this is doing but there are a few unknowns for me in your example. What is Format? Mainly. I am using a C++ function to write to the log defined as follows:

 void WriteMyLog(FString Msg, AActor * actor)
 {
     if (actor)
     {
         if (actor->GetNetMode() == ENetMode::NM_Client)
         {
             UE_LOG(MyClientLog, Warning, TEXT("%s"), *Msg);
         }
         else if (actor->GetNetMode() == ENetMode::NM_ListenServer)
         {
             UE_LOG(MyServerLog, Error, TEXT("%s"), *Msg);
         }
     }
     else
     {
         UE_LOG(MyLog, Log, TEXT("%s"), *Msg);
     }
 }


This is a global function that I plan on adding Debug preprocessors around but basically it is accessable across my entire project because it is declared within my main game's .h file.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hello, ArcainOne

Format in this case means that you are available to adjust your string with specifiers and flags as with C printf() function. If you like to learn more about it, please go here: https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Containers/FString/Printf/index.html http://www.cplusplus.com/reference/cstdio/printf/

Hope this helped!

more ▼

answered May 07 '15 at 08:04 AM

avatar image

Andrii Melnyk
1.8k 60 19 112

avatar image ArcainOne May 08 '15 at 05:31 AM

Okay, but I'm still not sure how that solves my original question, which is how do you change the color of the Log text in the log window. I have tried using SET_WARN_COLOR(COLOR_CYAN) but that does not appear to do anything...

avatar image ArcainOne May 08 '15 at 05:43 AM

Don't get me wrong I'm willing to accept a "There is no way to do it" but it seems a shame if there isn't a way, it would make debugging a bit easier...

avatar image GeekyPayback May 08 '15 at 07:33 AM

It looks like you are trying to write your own log file, there are already wiki pages that explain how to do it (its where my example came from).

How to write a custom log file with netmode and colour

Paste your code up, because my logs do come out in cyan, so that SET_WARN_COLOR works for me.

avatar image ArcainOne Jun 23 '15 at 11:11 PM

That looks exactly what I am trying to do. I actually got the whole net mode working but that looks to be a much better method. I'll try it out and it if works will be setting this to resolved!

avatar image Maxxomatik Feb 12 '18 at 04:14 PM

SET_WARN_COLOR doeas not work in 4.17, isn't it?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Still works for me in 4.18. put your entire file and the error message it gives and I'll try and help

more ▼

answered Feb 17 '18 at 08:16 AM

avatar image

GeekyPayback
55 6 9 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question