Logging is extremely important for outputting internal game data. Using log tools lets you print information into a handy little Output Log window in the UE4 editor.
When coding, we may sometimes want to send some debug information out to the UE log window. This is possible using the UE_LOG
macro. Log messages are an extremely important and convenient way to keep track of information in your program as you are developing it.
The UE_LOG
macro accepts a minimum of three parameters:
LogTemp
here to denote a log message in a temporary log)Do not forget the TEXT()
macro around your log message text! It promotes the enclosed text to Unicode (it prepends an L) when the compiler is set to run with Unicode on.
UE_LOG
also accepts a variable number of arguments, just like printf()
from the C programming language.
int intVar = 5;
float floatVar = 3.7f;
FString fstringVar = "an fstring variable";
UE_LOG(LogTemp, Warning, TEXT("Text, %d %f %s"), intVar, floatVar, *fstringVar );
There will be an asterisk *
just before FString
variables when using UE_LOG
to dereference the FString
to a regular C-style TCHAR
pointer.
Don't forget to clear your log messages after you no longer need them from the source!
18.226.187.199