39#if ENGINE_MAJOR_VERSION >= 5
40 inline static const FString PreConfigFileName = TEXT(
"LootLockerServerPreConfig.bytes");
44 UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category =
"LootLockerServer",
Meta = (EditCondition =
"bIsFileConfigLocked", EditConditionHides),
Meta = (MultiLine =
true),
Meta = (DisplayName =
"INFO:"), Transient)
45 FString FileConfigActiveNotice = "Settings are governed by the pre-configured file config shipped with the plugin and cannot be changed from the editor.";
46 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLockerServer",
Meta = (EditCondition = "!bIsFileConfigLocked"))
47 FString LootLockerServerKey = "";
48 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLockerServer",
Meta = (EditCondition = "!bIsFileConfigLocked"))
49 FString LootLockerDomainKey = "";
50 UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "LootLockerServer",
Meta = (EditCondition = "IsLegacyKey", EditConditionHides),
Meta = (MultiLine = true),
Meta = (DisplayName = "WARNING:"), Transient)
51 FString LegacyKeyWarning = "You are using a legacy API Key, please generate a new one here: https:
52 UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "LootLockerServer",
Meta = (EditCondition = "!IsValidGameVersion", EditConditionHides),
Meta = (MultiLine = true),
Meta = (DisplayName = "WARNING:"), Transient)
53 FString InvalidGameVersionWarning = "";
54 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLockerServer",
Meta = (EditCondition = "!bIsFileConfigLocked"))
55 FString GameVersion = "";
56 UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly,
Meta = (EditCondition = "false", EditConditionHides), Category = "LootLockerServer")
57 FString LootLockerVersion = "2021-06-01";
59 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLockerServer|Logging",
Meta = (EditCondition = "!bIsFileConfigLocked"))
60 ELootLockerServerLogLevel LimitLogLevelTo = ELootLockerServerLogLevel::Warning;
61 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLockerServer|Logging",
Meta = (EditCondition = "!bIsFileConfigLocked"))
62 bool LogOutsideOfEditor = false;
63 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLockerServer|Logging",
Meta = (EditCondition = "!bIsFileConfigLocked"))
64 bool bEnableFileLogging = false;
65 UPROPERTY(Config, EditAnywhere, BlueprintReadWrite, Category = "LootLockerServer|Logging",
Meta = (EditCondition = "bEnableFileLogging && !bIsFileConfigLocked", EditConditionHides))
66 FString LogFileName = TEXT("LootLockerServerLog");
67 UPROPERTY(Config, VisibleAnywhere, BlueprintReadOnly, Category = "LootLockerServer|Logging",
Meta = (EditCondition = "bEnableFileLogging", EditConditionHides),
Meta = (MultiLine = true),
Meta = (DisplayName = "Actual Log File (on current device)"), Transient)
68 FString LongLogFilePath = "";
70 FString LogFilePath = "";
73 static ELootLockerServerLogLevel GetConfiguredLogLevel()
75 return GetDefault<ULootLockerServerConfig>()->LimitLogLevelTo;
82 UFUNCTION(BlueprintCallable, Category =
"LootLocker|Logging")
83 static
void SetRuntimeLogLevel(ELootLockerServerLogLevel NewLevel);
88 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
89 static ELootLockerServerLogLevel GetRuntimeLogLevel();
95 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
96 static
void EnableFileLogging(const FString& FileName);
101 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
102 static
void DisableFileLogging();
107 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
108 static
bool IsFileLoggingEnabled();
113 UFUNCTION(BlueprintCallable, Category = "LootLocker|Logging")
114 static FString GetLogFilePath();
119 bool IsLegacyAPIKey()
const
121 return LootLockerServerKey.Find(
"dev_", ESearchCase::CaseSensitive) == -1 && LootLockerServerKey.Find(
"prod_", ESearchCase::CaseSensitive) == -1;
125 static
bool ShouldLog()
130 return GetDefault<ULootLockerServerConfig>()->LogOutsideOfEditor;
135 static
bool IsSemverString(const FString& str)
137#if ENGINE_MAJOR_VERSION >= 5
138 return std::regex_match(TCHAR_TO_UTF8(*str), SemverPattern);
144 virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
override
146 if (PropertyChangedEvent.GetPropertyName() ==
"LootLockerServerKey")
148 IsLegacyKey = IsLegacyAPIKey();
150 if (PropertyChangedEvent.GetPropertyName() ==
"GameVersion")
152 IsValidGameVersion = IsSemverString(GameVersion);
154 if (PropertyChangedEvent.GetPropertyName() ==
"bEnableFileLogging" || PropertyChangedEvent.GetPropertyName() ==
"LogFileName")
156 if (bEnableFileLogging)
158 EnableFileLogging(LogFileName.IsEmpty() ?
"LootLockerServerLog" : LogFileName);
162 DisableFileLogging();
165 UObject::PostEditChangeProperty(PropertyChangedEvent);
168 virtual void PostInitProperties()
override
170 IsLegacyKey = IsLegacyAPIKey();
171 IsValidGameVersion = IsSemverString(GameVersion);
173 ApplyFileConfigIfPresent();
177 if (!bIsFileConfigLocked)
179 if(bEnableFileLogging)
181 EnableFileLogging(LogFileName.IsEmpty() ?
"LootLockerServerLog" : LogFileName);
185 DisableFileLogging();
188 UObject::PostInitProperties();
191 UPROPERTY(Config, VisibleInstanceOnly,
Meta = (EditCondition =
"false", EditConditionHides), Transient, Category =
"LootLockerServer")
192 bool IsLegacyKey = false;
193 UPROPERTY(Config, VisibleInstanceOnly,
Meta = (EditCondition = "false", EditConditionHides), Transient, Category = "LootLockerServer")
194 bool IsValidGameVersion = true;
195 UPROPERTY(Config, VisibleInstanceOnly,
Meta = (EditCondition = "false", EditConditionHides), Transient, Category = "LootLockerServer")
196 bool bIsFileConfigLocked = false;
197#if ENGINE_MAJOR_VERSION >= 5
198 inline static bool bFileConfigChecked =
false;
199 inline static TOptional<FLootLockerServerFileConfig> FileConfig;
201 static bool bFileConfigChecked;
202 static TOptional<FLootLockerServerFileConfig> FileConfig;
204 static void LoadFileConfig();
205 void ApplyFileConfigIfPresent();
206#if ENGINE_MAJOR_VERSION >= 5
207 inline static const std::regex SemverPattern = std::regex(
"^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:\\.(0|[1-9]\\d*))?(?:\\.(0|[1-9]\\d*))?$");