Saving Code as a Macro

Is using VS 2019 for my Unreal projects right now and I have had to do a TON of debugging to get my code to work. I have been using the Log macro a lot to see where things start and stop firing.

UE_LOG(LogTemp, Warning, TEXT(""))

Is there anyway to save this line of code as a “macro” that I can then use to insert into my code without having to type the full thing out every single time. Would be greatly helpful and time saving.

#include <string>
#define PRINTLINE(std::string Text)(UE_LOG(LogTemp, Warning, TEXT(Text)))

Now, usage -

PRINTLINE("MyLine")

This might or might not work, as I am a pretty bad programmer. Test for yourself and see if it works. It might throw a lot of compiler errors, so be careful!

I wouln’t use std::string. I would write

#define UE_LOG_TEMP(MESSAGE, ...) UE_LOG(LogTemp, Warning, MESSAGE, ##__VA_ARGS__)

Then you can do

UE_LOG_TEMP(TEXT("Hello %i"), 52)

Privacy & Terms