Skip to content
Snippets Groups Projects
Commit 38d3784f authored by Jonathan Ehret's avatar Jonathan Ehret
Browse files

allow closing log streams, e.g., to free the file handle or to be sure, that...

allow closing log streams, e.g., to free the file handle or to be sure, that it is closed and noone will write into it anymore
parent 3c7b7801
No related branches found
No related tags found
1 merge request!20remove all streams on session end, so that logging into a not created stream...
Pipeline #348257 failed
......@@ -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
......@@ -108,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))
......
......@@ -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;
......
......@@ -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.
*
......
......@@ -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);
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment