Yasiu Math
1
Collection of mathematic functions that help create game mechanics and procedural tools
Toggle main menu visibility
Loading...
Searching...
No Matches
YasiuMathLogs.h
1
#pragma once
2
3
4
#define RunVerb Log
5
#define CompVerb Log
6
7
8
#include "CoreMinimal.h"
9
#include "Runtime/Launch/Resources/Version.h"
10
11
12
DECLARE_LOG_CATEGORY_EXTERN(YasiuMathPlugin, Log, Log);
13
14
15
FString ReadObName(
const
class
UObject* ob );
16
17
FString ReadObName(
const
class
AActor* act );
18
19
FString ReadObName(
const
class
UActorComponent* cmp );
20
21
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION <= 1
22
#include "Logging/LogMacros.h"
23
24
template
<
typename
T>
25
FString ToFString(
const
T& Val )
26
{
27
if
constexpr
( TIsPointer<T>::Value && TIsDerivedFrom<T, UObject>::Value ) {
28
return
Val ? Val->GetName() : TEXT(
"nullptr"
);
29
}
30
else
if
constexpr
( TIsEnum<T>::Value ) {
31
return
FString::Printf(TEXT(
"%d "
),
static_cast<
int
>
(Val));
// cast enum to int
32
}
33
else
{
34
return
FString::Printf(TEXT(
"%s "
), *LexToString(Val));
35
}
36
}
template
<
typename
... Args>
37
FString BuildLogMessage(
const
FString& Msg, Args&& ... args )
38
{
39
TArray<FString> Parts = {ToFString(args) ...};
40
return
Msg + TEXT(
", Values: "
) + FString::Join(Parts, TEXT(
", "
));
41
}
42
43
#define YASIUMATHLOG(LogVerb, LogMsg) \
44
do { \
45
UE_LOG(YasiuMathPlugin, LogVerb, TEXT(LogMsg)); \
46
} while(0)
47
48
#define YASIUMATHLOG_MULTI(LogVerb, LogMsg, ...) \
49
do { \
50
const FString FormattedMsg = FString::Format(TEXT("{0} {1}"), { ReadObName(this), LogMsg }); \
51
const FString MessageWithValues = BuildLogMessage(FormattedMsg, __VA_ARGS__);\
52
UE_LOG(YasiuMathPlugin, LogVerb, TEXT("%s"), *MessageWithValues); \
53
} while(0)
54
#else
55
#include "Logging/StructuredLog.h"
56
57
#define YASIUMATHLOG(LogVerb, LogMsg) \
58
UE_LOGFMT(YasiuMathPlugin, LogVerb, "{nm}({funcName}) " LogMsg, \
59
ReadObName(this), \
60
__FUNCTION__)
61
62
#define YASIUMATHLOG_MULTI(LogVerb, LogMsg, ...) \
63
UE_LOGFMT(YasiuMathPlugin, LogVerb, "{nm}({funcName}) " LogMsg, \
64
ReadObName(this), \
65
__FUNCTION__ \
66
, __VA_ARGS__)
67
#endif
Source
YasiuMath
Public
YasiuMathLogs.h
Generated by
1.17.0