diff --git a/Source/UniversalLogging/Private/LogStream.cpp b/Source/UniversalLogging/Private/LogStream.cpp index fd9d6a788c80fb571dd6f70f685936c910193a5c..c20b9d8f4aa7f00b108ab1b4dde60dd6a5ba6cec 100644 --- a/Source/UniversalLogging/Private/LogStream.cpp +++ b/Source/UniversalLogging/Private/LogStream.cpp @@ -48,6 +48,16 @@ FString LogStreamImpl::GetFilename() return Filename; } +void LogStreamImpl::SetPrefix(FString Prefix) +{ + MessagePrefix = Prefix; +} + +FString LogStreamImpl::GetPrefix() const +{ + return MessagePrefix; +} + void LogStreamImpl::SetOnScreen(const bool Val) { bOnScreen = Val; @@ -177,5 +187,5 @@ void LogStreamImpl::Write(const FString Text) return; if (!Log_File_Stream->GetIsOpen()) Open(); - Log_File_Stream->Write(Text); + Log_File_Stream->Write(MessagePrefix + Text); } \ No newline at end of file diff --git a/Source/UniversalLogging/Private/LogStream.h b/Source/UniversalLogging/Private/LogStream.h index f63b3f1c49dc9d4c48fa355b5ffbf1ad18d1ce97..ab28299bdd218dc4407a4f50b3c2dbf6fc46cf0a 100644 --- a/Source/UniversalLogging/Private/LogStream.h +++ b/Source/UniversalLogging/Private/LogStream.h @@ -16,6 +16,9 @@ public: FString GetFilepath() override; FString GetFilename() override; + void SetPrefix(FString Prefix) override; + FString GetPrefix() const override; + void SetOnScreen(const bool Val) override; bool GetOnScreen() const override; void SetOnScreenColor(const FColor Color) override; @@ -48,6 +51,7 @@ public: private: const FString Filepath; const FString Filename; + FString MessagePrefix; bool bPer_Session; bool bOnScreen; diff --git a/Source/UniversalLogging/Private/UniLogBlueprintFunctionLibrary.cpp b/Source/UniversalLogging/Private/UniLogBlueprintFunctionLibrary.cpp index 7a9c74589ad2d6c7b07ab8a0acfea9380025bb79..da7f1f9aebe6aee9b6d4794ac9a881e89bfdd98c 100644 --- a/Source/UniversalLogging/Private/UniLogBlueprintFunctionLibrary.cpp +++ b/Source/UniversalLogging/Private/UniLogBlueprintFunctionLibrary.cpp @@ -26,7 +26,7 @@ FString UUniLogBlueprintFunctionLibrary::GetSessionIdentifier() } 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 OnScreenBackgroundColor, float OnScreenSize, float OnScreenDuration, @@ -36,6 +36,7 @@ void UUniLogBlueprintFunctionLibrary::NewLogStream(const FString StreamName, con bool bLogOnScreenOnSlaves/* = false*/) { auto LogStream = UniLog.NewLogStream(StreamName, Filepath, Filename, bPer_Session, bLogOnMaster, bLogOnSlaves); + LogStream->SetPrefix(Prefix); LogStream->SetOnScreen(bOnScreen); LogStream->SetOnScreenColor(OnScreenColor); LogStream->SetOnScreenBackgroundColor(OnScreenBackgroundColor); diff --git a/Source/UniversalLogging/Public/ILogStream.h b/Source/UniversalLogging/Public/ILogStream.h index 35063629cc149c5a991018dd382bb792f8a6f6fd..49ef4d25ee7f7a764ea7569720728815d38f5c8c 100644 --- a/Source/UniversalLogging/Public/ILogStream.h +++ b/Source/UniversalLogging/Public/ILogStream.h @@ -7,6 +7,9 @@ public: virtual FString GetFilename() = 0; virtual bool GetIsValid() = 0; + virtual void SetPrefix(FString Prefix) = 0; + virtual FString GetPrefix() const = 0; + virtual void SetOnScreen(const bool Val) = 0; virtual bool GetOnScreen() const = 0; virtual void SetOnScreenColor(const FColor Color) = 0; diff --git a/Source/UniversalLogging/Public/UniLogBlueprintFunctionLibrary.h b/Source/UniversalLogging/Public/UniLogBlueprintFunctionLibrary.h index fd9c7053e70800dbad45d44a1479d0d325e3bd09..ce5d6e4dcaa57c820574343828c664436f45c299 100644 --- a/Source/UniversalLogging/Public/UniLogBlueprintFunctionLibrary.h +++ b/Source/UniversalLogging/Public/UniLogBlueprintFunctionLibrary.h @@ -23,7 +23,7 @@ class UUniLogBlueprintFunctionLibrary : public UBlueprintFunctionLibrary static FString GetSessionIdentifier(); 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, FColor OnScreenColor = FColor(255, 255, 255, 255), FColor OnScreenBackgroundColor = FColor(0, 0, 0, 128),