Skip to content
Snippets Groups Projects
Commit 639d2a9e authored by mbellgardt's avatar mbellgardt
Browse files

Add a Prefix to LogStreams to distinguish different streams in the same file.

parent 7c369b5b
Branches
No related tags found
2 merge requests!16Develop,!6Feature/multiple streams per file
...@@ -48,6 +48,16 @@ FString LogStreamImpl::GetFilename() ...@@ -48,6 +48,16 @@ FString LogStreamImpl::GetFilename()
return Filename; return Filename;
} }
void LogStreamImpl::SetPrefix(FString Prefix)
{
MessagePrefix = Prefix;
}
FString LogStreamImpl::GetPrefix() const
{
return MessagePrefix;
}
void LogStreamImpl::SetOnScreen(const bool Val) void LogStreamImpl::SetOnScreen(const bool Val)
{ {
bOnScreen = Val; bOnScreen = Val;
...@@ -177,5 +187,5 @@ void LogStreamImpl::Write(const FString Text) ...@@ -177,5 +187,5 @@ void LogStreamImpl::Write(const FString Text)
return; return;
if (!Log_File_Stream->GetIsOpen()) if (!Log_File_Stream->GetIsOpen())
Open(); Open();
Log_File_Stream->Write(Text); Log_File_Stream->Write(MessagePrefix + Text);
} }
\ No newline at end of file
...@@ -16,6 +16,9 @@ public: ...@@ -16,6 +16,9 @@ public:
FString GetFilepath() override; FString GetFilepath() override;
FString GetFilename() override; FString GetFilename() override;
void SetPrefix(FString Prefix) override;
FString GetPrefix() const override;
void SetOnScreen(const bool Val) override; void SetOnScreen(const bool Val) override;
bool GetOnScreen() const override; bool GetOnScreen() const override;
void SetOnScreenColor(const FColor Color) override; void SetOnScreenColor(const FColor Color) override;
...@@ -48,6 +51,7 @@ public: ...@@ -48,6 +51,7 @@ public:
private: private:
const FString Filepath; const FString Filepath;
const FString Filename; const FString Filename;
FString MessagePrefix;
bool bPer_Session; bool bPer_Session;
bool bOnScreen; bool bOnScreen;
......
...@@ -26,7 +26,7 @@ FString UUniLogBlueprintFunctionLibrary::GetSessionIdentifier() ...@@ -26,7 +26,7 @@ FString UUniLogBlueprintFunctionLibrary::GetSessionIdentifier()
} }
void UUniLogBlueprintFunctionLibrary::NewLogStream(const FString StreamName, const FString Filepath, void UUniLogBlueprintFunctionLibrary::NewLogStream(const FString StreamName, const FString Filepath,
const FString Filename, bool bPer_Session, bool bOnScreen/* = false*/, const FString Filename, FString Prefix, bool bPer_Session, bool bOnScreen/* = false*/,
FColor OnScreenColor/* = FColor(0, 0, 255, 0)*/, FColor OnScreenColor/* = FColor(0, 0, 255, 0)*/,
FColor OnScreenBackgroundColor, float OnScreenSize, FColor OnScreenBackgroundColor, float OnScreenSize,
float OnScreenDuration, float OnScreenDuration,
...@@ -36,6 +36,7 @@ void UUniLogBlueprintFunctionLibrary::NewLogStream(const FString StreamName, con ...@@ -36,6 +36,7 @@ void UUniLogBlueprintFunctionLibrary::NewLogStream(const FString StreamName, con
bool bLogOnScreenOnSlaves/* = false*/) bool bLogOnScreenOnSlaves/* = false*/)
{ {
auto LogStream = UniLog.NewLogStream(StreamName, Filepath, Filename, bPer_Session, bLogOnMaster, bLogOnSlaves); auto LogStream = UniLog.NewLogStream(StreamName, Filepath, Filename, bPer_Session, bLogOnMaster, bLogOnSlaves);
LogStream->SetPrefix(Prefix);
LogStream->SetOnScreen(bOnScreen); LogStream->SetOnScreen(bOnScreen);
LogStream->SetOnScreenColor(OnScreenColor); LogStream->SetOnScreenColor(OnScreenColor);
LogStream->SetOnScreenBackgroundColor(OnScreenBackgroundColor); LogStream->SetOnScreenBackgroundColor(OnScreenBackgroundColor);
......
...@@ -7,6 +7,9 @@ public: ...@@ -7,6 +7,9 @@ public:
virtual FString GetFilename() = 0; virtual FString GetFilename() = 0;
virtual bool GetIsValid() = 0; virtual bool GetIsValid() = 0;
virtual void SetPrefix(FString Prefix) = 0;
virtual FString GetPrefix() const = 0;
virtual void SetOnScreen(const bool Val) = 0; virtual void SetOnScreen(const bool Val) = 0;
virtual bool GetOnScreen() const = 0; virtual bool GetOnScreen() const = 0;
virtual void SetOnScreenColor(const FColor Color) = 0; virtual void SetOnScreenColor(const FColor Color) = 0;
......
...@@ -23,7 +23,7 @@ class UUniLogBlueprintFunctionLibrary : public UBlueprintFunctionLibrary ...@@ -23,7 +23,7 @@ class UUniLogBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
static FString GetSessionIdentifier(); static FString GetSessionIdentifier();
UFUNCTION(BlueprintCallable, Category = "UniLog") UFUNCTION(BlueprintCallable, Category = "UniLog")
static void NewLogStream(const FString StreamName, const FString Filepath, const FString Filename, static void NewLogStream(const FString StreamName, const FString Filepath, const FString Filename, FString Prefix,
bool bPer_Session = false, bool bOnScreen = false, bool bPer_Session = false, bool bOnScreen = false,
FColor OnScreenColor = FColor(255, 255, 255, 255), FColor OnScreenColor = FColor(255, 255, 255, 255),
FColor OnScreenBackgroundColor = FColor(0, 0, 0, 128), FColor OnScreenBackgroundColor = FColor(0, 0, 0, 128),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment