How to create wrapper function for UE_LOG? with varargs

I want create my own function

DebugLog(const TCHAR* format, …)
{
UE_LOG(…) // ? HOW?
}

Used example from FOutputDevice.

.h

class GAME_API MyLog
{
public:
	VARARG_DECL( void, void, {}, MyLogf, VARARG_NONE, const TCHAR*, VARARG_NONE, VARARG_NONE );
};

.cpp

VARARG_BODY( void, MyLog::MyLogf, const TCHAR*, VARARG_NONE )
{
	GROWABLE_LOGF(GLog->Serialize(Buffer, ELogVerbosity::Log, NAME_None))
}

could you explain this code?
I am trying to accomplish a similar thing, but I have no idea what’s going on with those macros, what actually happens there and how it leads to something that would be the wrapper debug function you posted in your question.
Could you post an example on how to use your Wrapper Debug function?

hey pro :slight_smile:

I made a few custom macros for my Print logs
Check these out

#define P_LOG(s, ...)			UE_LOG(LogTemp, Log,		TEXT(s), ##__VA_ARGS__)
#define P_WARNING(s, ...)		UE_LOG(LogTemp, Warning,	TEXT(s), ##__VA_ARGS__)
#define P_ERROR(s, ...)			UE_LOG(LogTemp, Error,		TEXT(s), ##__VA_ARGS__)

#define P_SCREEN_LOG(s)			{ if(GEngine) {GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Green, s); }}
#define P_SCREEN_WARNING(s)		{ if(GEngine) {GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Yellow, s); }}
#define P_SCREEN_ERROR(s)			{ if(GEngine) {GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Red, s); }}
#define P_SCREEN_MESSAGE(s, c)		{ if (GEngine) { GEngine->AddOnScreenDebugMessage(-1, 2.0f, c, s); }}

#define P_SCREEN_LOG_T(s, t)			{ if(GEngine) {GEngine->AddOnScreenDebugMessage(-1, t, FColor::Green, s); }}
#define P_SCREEN_WARNING_T(s, t)		{ if(GEngine) {GEngine->AddOnScreenDebugMessage(-1, t, FColor::Yellow, s); }}
#define P_SCREEN_ERROR_T(s, t)			{ if(GEngine) {GEngine->AddOnScreenDebugMessage(-1, t, FColor::Red, s); }}
#define P_SCREEN_MESSAGE_T(s, c, t)		{ if(GEngine) { GEngine->AddOnScreenDebugMessage(-1, t, c, s); }}