diff --git a/Source/UniversalLogging/Private/UniLogBlueprintFunctionLibrary.cpp b/Source/UniversalLogging/Private/UniLogBlueprintFunctionLibrary.cpp index da7f1f9aebe6aee9b6d4794ac9a881e89bfdd98c..a38fa304ae2b682e8f812e95deb70e2292e5f4aa 100644 --- a/Source/UniversalLogging/Private/UniLogBlueprintFunctionLibrary.cpp +++ b/Source/UniversalLogging/Private/UniLogBlueprintFunctionLibrary.cpp @@ -62,3 +62,8 @@ void UUniLogBlueprintFunctionLibrary::ModifyLogStream(const FString StreamName, LogStream->SetLogOnScreenOnMaster(bLogOnScreenOnMaster); LogStream->SetLogOnScreenOnSlaves(bLogOnScreenOnSlaves); } + +void UUniLogBlueprintFunctionLibrary::CloseLogStream(const FString StreamName) +{ + UniLog.CloseLogStream(StreamName); +} \ No newline at end of file diff --git a/Source/UniversalLogging/Private/UniversalLogging.cpp b/Source/UniversalLogging/Private/UniversalLogging.cpp index 3fce5e3c4036a310b0dc7f2c25dd2a30b1b860cf..0414fecc10fa8bd3a0dfe78829ebe8e58281c459 100644 --- a/Source/UniversalLogging/Private/UniversalLogging.cpp +++ b/Source/UniversalLogging/Private/UniversalLogging.cpp @@ -71,6 +71,8 @@ void UniversalLoggingImpl::OnSessionEnd(const bool) { Elem.Value->Close(); } + + Streams.Empty(); } void UniversalLoggingImpl::OnPostActorTick(UWorld* World, ELevelTick LevelTick, float WhateverThisIsDeltaTimeMaybe) @@ -106,6 +108,15 @@ ILogStream* UniversalLoggingImpl::NewLogStream(const FString StreamName, const F return Streams[StreamName].Get(); } +void UniversalLoggingImpl::CloseLogStream(const FString StreamName) +{ + if(Streams.Contains(StreamName)) + { + Streams[StreamName]->Close(); + Streams.Remove(StreamName); + } +} + ILogStream * UniversalLoggingImpl::GetLogStream(const FString StreamName) { if (Streams.Contains(StreamName)) diff --git a/Source/UniversalLogging/Private/UniversalLogging.h b/Source/UniversalLogging/Private/UniversalLogging.h index d6a98cc1fc847640b53d2d6f1966f26c5ccb9291..0c5674d138c0be375bbdd3be4208fe12c19eafeb 100644 --- a/Source/UniversalLogging/Private/UniversalLogging.h +++ b/Source/UniversalLogging/Private/UniversalLogging.h @@ -25,6 +25,7 @@ public: ILogStream* NewLogStream(const FString StreamName, const FString Filepath, const FString Filename, bool bPer_Session = false, const bool bLogOnMaster = true, const bool bLogOnSlaves = false) override; + void CloseLogStream(const FString StreamName) override; ILogStream* GetLogStream(const FString StreamName) override; ILogStream* GetDefaultLogStream() override; FString GetSessionIdentifier() override; diff --git a/Source/UniversalLogging/Public/IUniversalLogging.h b/Source/UniversalLogging/Public/IUniversalLogging.h index b76c7ec2ebc693c33a0700873d3e7c1d244ee217..707b8824b5565343d397aaf83c67847273a34b0d 100644 --- a/Source/UniversalLogging/Public/IUniversalLogging.h +++ b/Source/UniversalLogging/Public/IUniversalLogging.h @@ -47,6 +47,12 @@ public: bool bPer_Session = false, const bool bLogOnMaster = true, const bool bLogOnSlaves = false) = 0; + /** + * Closes a specific named log stream. + * This is done by default when a session stops, but can also be done manually if needed + */ + virtual void CloseLogStream(const FString StreamName) = 0; + /** * Getter for log streams. * diff --git a/Source/UniversalLogging/Public/UniLogBlueprintFunctionLibrary.h b/Source/UniversalLogging/Public/UniLogBlueprintFunctionLibrary.h index ce5d6e4dcaa57c820574343828c664436f45c299..ad47730744fd189af2390d8cac9399e536d4ffdc 100644 --- a/Source/UniversalLogging/Public/UniLogBlueprintFunctionLibrary.h +++ b/Source/UniversalLogging/Public/UniLogBlueprintFunctionLibrary.h @@ -37,4 +37,7 @@ class UUniLogBlueprintFunctionLibrary : public UBlueprintFunctionLibrary FColor OnScreenBackgroundColor = FColor(0, 0, 0, 128), float OnScreenSize = 1.0, float OnScreenDuration = 5.0, bool bLogToDefaultLog = false, bool bLogOnScreenOnMaster = true, bool bLogOnScreenOnSlaves = false); + + UFUNCTION(BlueprintCallable, Category = "UniLog") + static void CloseLogStream(const FString StreamName); };