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

always setup debug logs before using them to have all messages logged and a...

always setup debug logs before using them to have all messages logged and a individual file per session, avoiding a prior bug in the UniLog plugin (which is however, also fixed by now)
parent db9fc0f0
No related branches found
No related tags found
No related merge requests found
...@@ -10,9 +10,14 @@ ...@@ -10,9 +10,14 @@
#include "IUniversalLogging.h" #include "IUniversalLogging.h"
#include "Help/SFUtils.h" #include "Help/SFUtils.h"
bool FSFLoggingUtils::bDebugLogsSetUp = false;
void FSFLoggingUtils::Log(const FString Text, const bool Error /*=false*/) void FSFLoggingUtils::Log(const FString Text, const bool Error /*=false*/)
{ {
if (!bDebugLogsSetUp) {
SetupDebugLoggingStreams();
}
if (Error) if (Error)
{ {
UniLog.Log(Text, "SFErrorLog"); UniLog.Log(Text, "SFErrorLog");
...@@ -30,7 +35,6 @@ void FSFLoggingUtils::Log(const FString Text, const bool Error /*=false*/) ...@@ -30,7 +35,6 @@ void FSFLoggingUtils::Log(const FString Text, const bool Error /*=false*/)
void FSFLoggingUtils::SetupDebugLoggingStreams() void FSFLoggingUtils::SetupDebugLoggingStreams()
{ {
const FString Timestamp = FDateTime::Now().ToString(); const FString Timestamp = FDateTime::Now().ToString();
FString LogFilename = "SFLog_" + Timestamp + ".txt"; FString LogFilename = "SFLog_" + Timestamp + ".txt";
...@@ -44,6 +48,12 @@ void FSFLoggingUtils::SetupDebugLoggingStreams() ...@@ -44,6 +48,12 @@ void FSFLoggingUtils::SetupDebugLoggingStreams()
SFErrorLog->SetPrefix(TEXT("Error: ")); SFErrorLog->SetPrefix(TEXT("Error: "));
SFErrorLog->SetLogOnScreenOnMaster(true); SFErrorLog->SetLogOnScreenOnMaster(true);
SFErrorLog->SetOnScreenColor(FColor::Red); SFErrorLog->SetOnScreenColor(FColor::Red);
#if WITH_EDITOR
FEditorDelegates::BeginPIE.AddStatic(&FSFLoggingUtils::OnSessionEnd);
#endif
bDebugLogsSetUp = true;
} }
void FSFLoggingUtils::SetupParticipantLoggingStream(const FString& ParticipantInfix) void FSFLoggingUtils::SetupParticipantLoggingStream(const FString& ParticipantInfix)
...@@ -51,3 +61,8 @@ void FSFLoggingUtils::SetupParticipantLoggingStream(const FString& ParticipantIn ...@@ -51,3 +61,8 @@ void FSFLoggingUtils::SetupParticipantLoggingStream(const FString& ParticipantIn
ILogStream* ParticipantLog = UniLog.NewLogStream("ParticipantLog", "StudyFramework/StudyLogs/ParticipantLogs", ILogStream* ParticipantLog = UniLog.NewLogStream("ParticipantLog", "StudyFramework/StudyLogs/ParticipantLogs",
ParticipantInfix + ".txt", false); ParticipantInfix + ".txt", false);
} }
void FSFLoggingUtils::OnSessionEnd(const bool)
{
bDebugLogsSetUp = false;
}
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
void FSFPlugin::StartupModule() void FSFPlugin::StartupModule()
{ {
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
FSFLoggingUtils::SetupDebugLoggingStreams();
} }
void FSFPlugin::ShutdownModule() void FSFPlugin::ShutdownModule()
......
...@@ -14,9 +14,15 @@ public: ...@@ -14,9 +14,15 @@ public:
// Log into Console and errors also on Screen, works also in Shipping build in contrast to UE_LOG // Log into Console and errors also on Screen, works also in Shipping build in contrast to UE_LOG
static void Log(FString Text, bool Error = false); static void Log(FString Text, bool Error = false);
static void SetupParticipantLoggingStream(const FString& ParticipantInfix);
static void OnSessionEnd(const bool);
private:
// To setup the debugging logs to be used // To setup the debugging logs to be used
static void SetupDebugLoggingStreams(); static void SetupDebugLoggingStreams();
static void SetupParticipantLoggingStream(const FString& ParticipantInfix); static bool bDebugLogsSetUp;
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment