Skip to content

Commit

Permalink
Add log verbosity (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjon2040 authored and MothDoctor committed Oct 25, 2021
1 parent 7893e25 commit 0f57985
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
27 changes: 26 additions & 1 deletion Source/Flow/Private/Nodes/Utils/FlowNode_Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,27 @@ UFlowNode_Log::UFlowNode_Log(const FObjectInitializer& ObjectInitializer)

void UFlowNode_Log::ExecuteInput(const FName& PinName)
{
UE_LOG(LogFlow, Warning, TEXT("%s"), *Message);
switch (Verbosity)
{
case EFlowLogVerbosity::Log:
UE_LOG(LogFlow, Log, TEXT("%s"), *Message);
break;
case EFlowLogVerbosity::Warning:
UE_LOG(LogFlow, Warning, TEXT("%s"), *Message);
break;
case EFlowLogVerbosity::Error:
UE_LOG(LogFlow, Error, TEXT("%s"), *Message);
break;
case EFlowLogVerbosity::Verbose:
UE_LOG(LogFlow, Verbose, TEXT("%s"), *Message);
break;
case EFlowLogVerbosity::VeryVerbose:
UE_LOG(LogFlow, VeryVerbose, TEXT("%s"), *Message);
break;
case EFlowLogVerbosity::Fatal:
UE_LOG(LogFlow, Fatal, TEXT("%s"), *Message);
default:;
}

if (bPrintToScreen)
{
Expand All @@ -30,6 +50,11 @@ void UFlowNode_Log::ExecuteInput(const FName& PinName)
#if WITH_EDITOR
FString UFlowNode_Log::GetNodeDescription() const
{
if (Verbosity == EFlowLogVerbosity::Fatal)
{
return FString::Printf(TEXT("FATAL LOG: %s"), *Message);
}

return Message;
}
#endif
20 changes: 20 additions & 0 deletions Source/Flow/Public/Nodes/Utils/FlowNode_Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
#include "Nodes/FlowNode.h"
#include "FlowNode_Log.generated.h"

UENUM(BlueprintType)
enum class EFlowLogVerbosity : uint8
{
Log,
Warning,
Error,
Verbose,
VeryVerbose,

/**
* Here be dragons
* This is the fatal log which means it will literally completely crash your editor/game.
* You've been warned. Use with caution.
*/
Fatal UMETA(DisplaName = "Fatal (USE WITH CAUTION)")
};

/**
* Adds message to log
* Optionally shows message on screen
Expand All @@ -16,6 +33,9 @@ class FLOW_API UFlowNode_Log : public UFlowNode
UPROPERTY(EditAnywhere, Category = "Flow")
FString Message;

UPROPERTY(EditAnywhere, Category = "Flow")
EFlowLogVerbosity Verbosity;

UPROPERTY(EditAnywhere, Category = "Flow")
bool bPrintToScreen;

Expand Down

0 comments on commit 0f57985

Please sign in to comment.