A single header file with useful macros for logging in Unreal Engine projects. These macros expand usage of standart UE_LOG macro. Macros with _PRINTF suffix can have formatted text (see example), without - just const strings.
Usage example:
#pragma once
#include "CoreMinimal.h"
#include "LogMacros.h"
#include "MyClass.generated.h"
UCLASS()
class UMyClass : public UObject
{
GENERATED_BODY()
public:
void Log()
{
/* Simple log */
LOG(LogTemp, "Log from my function.");
/* Formatted log */
LOG_PRINTF(LogTemp, "Log with format: %s %d ", TEXT("some text"), 123);
/* Log with desired verbosity */
LOG_VERBOSITY(LogTemp, Warning, "Custom verbosity.");
/* Log warning (don't have to specify verbosity) */
LOG_WARNING(LogTemp, "Some warning.");
/* Log error (don't have to specify verbosity) */
LOG_ERROR(LogTemp, "Some error.")
}
};
Calling UMyClass::Log function will print this:
LogTemp: UMyClass::Log (19): Log from my function.
LogTemp: UMyClass::Log (22): Log with format: some text 123
LogTemp: Warning: UMyClass::Log (25): Custom verbosity.
LogTemp: Warning: UMyClass::Log (28): Some warning.
LogTemp: Error: UMyClass::Log (31): Some error.
File also contains additional macros to help build your own custom log macros.