From 93a9c9d100b4df0d2e8e71d31b4fe2f7ba51f9c7 Mon Sep 17 00:00:00 2001 From: Yatima1460 Date: Sat, 23 Sep 2017 18:47:27 +0200 Subject: [PATCH] added node description and fixed compilation for all the targets where logging is disabled --- .../UE4Logger/Private/UE4LoggerBPLibrary.cpp | 11 ++-- Source/UE4Logger/Public/UE4LoggerBPLibrary.h | 50 ++++++++----------- UE4Logger.uplugin | 4 +- 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/Source/UE4Logger/Private/UE4LoggerBPLibrary.cpp b/Source/UE4Logger/Private/UE4LoggerBPLibrary.cpp index 5e62c72..5dce432 100644 --- a/Source/UE4Logger/Private/UE4LoggerBPLibrary.cpp +++ b/Source/UE4Logger/Private/UE4LoggerBPLibrary.cpp @@ -11,14 +11,14 @@ UUE4LoggerBPLibrary::UUE4LoggerBPLibrary(const FObjectInitializer& ObjectInitial #pragma region verbosity void UUE4LoggerBPLibrary::SetLogLevel(UObject * WorldContextObject, ELogLevel eLogLevel) { -#if !UE_BUILD_SHIPPING +#if !NO_LOGGING LogBlueprintUserMessages.SetVerbosity((ELogVerbosity::Type)eLogLevel); #endif } ELogLevel UUE4LoggerBPLibrary::GetLogLevel(UObject * WorldContextObject) { -#if !UE_BUILD_SHIPPING +#if !NO_LOGGING return (ELogLevel)LogBlueprintUserMessages.GetVerbosity(); #else return ELogLevel::None; @@ -27,7 +27,7 @@ ELogLevel UUE4LoggerBPLibrary::GetLogLevel(UObject * WorldContextObject) bool UUE4LoggerBPLibrary::IsLogLevelSuppressed(UObject * WorldContextObject, ELogLevel eLogLevel) { -#if !UE_BUILD_SHIPPING +#if !NO_LOGGING return LogBlueprintUserMessages.IsSuppressed((ELogVerbosity::Type)eLogLevel); #else return true; @@ -51,7 +51,7 @@ void UUE4LoggerBPLibrary::LogError(UObject * WorldContextObject, FString InStrin UUE4LoggerBPLibrary::Log(WorldContextObject, InString, ELogLevel::Error, bPrintToLog, bPrintToScreen, Duration); } -void UUE4LoggerBPLibrary::CrashEngine(UObject * WorldContextObject, FString Message) +void UUE4LoggerBPLibrary::LogFatal(UObject * WorldContextObject, FString Message) { UUE4LoggerBPLibrary::Log(WorldContextObject, Message, ELogLevel::Fatal, true, false, 0.0f); } @@ -60,6 +60,7 @@ void UUE4LoggerBPLibrary::CrashEngine(UObject * WorldContextObject, FString Mess #pragma region generic function void UUE4LoggerBPLibrary::Log(UObject* WorldContextObject, FString InString, ELogLevel eLogLevel, bool bPrintToLog, bool bPrintToScreen, float Duration) { +#if !NO_LOGGING FColor logColor = FColor::White; switch (eLogLevel) { @@ -130,7 +131,7 @@ void UUE4LoggerBPLibrary::Log(UObject* WorldContextObject, FString InString, ELo } } -#if !UE_BUILD_SHIPPING + // Also output to the screen if possible and hide suppressed log levels if (bPrintToScreen && !LogBlueprintUserMessages.IsSuppressed((ELogVerbosity::Type)eLogLevel)) { diff --git a/Source/UE4Logger/Public/UE4LoggerBPLibrary.h b/Source/UE4Logger/Public/UE4LoggerBPLibrary.h index 65c0d78..eb52f05 100644 --- a/Source/UE4Logger/Public/UE4LoggerBPLibrary.h +++ b/Source/UE4Logger/Public/UE4LoggerBPLibrary.h @@ -9,26 +9,7 @@ #include #include "UE4LoggerBPLibrary.generated.h" - -/* -* Function library class. -* Each function in it is expected to be static and represents blueprint node that can be called in any blueprint. -* -* When declaring function you can define metadata for the node. Key function specifiers will be BlueprintPure and BlueprintCallable. -* BlueprintPure - means the function does not affect the owning object in any way and thus creates a node without Exec pins. -* BlueprintCallable - makes a function which can be executed in Blueprints - Thus it has Exec pins. -* DisplayName - full name of the node, shown when you mouse over the node and in the blueprint drop down menu. -* Its lets you name the node using characters not allowed in C++ function names. -* CompactNodeTitle - the word(s) that appear on the node. -* Keywords - the list of keywords that helps you to find node when you search for it using Blueprint drop-down menu. -* Good example is "Print String" node which you can find also by using keyword "log". -* Category - the category your node will be under in the Blueprint drop-down menu. -* -* For more info on custom blueprint nodes visit documentation: -* https://wiki.unrealengine.com/Custom_Blueprint_Node_Creation -*/ - -UENUM(BlueprintType, meta = (Keywords = "UE4logger log level", CompactNodeTitle = "Log Level")) +UENUM(BlueprintType, meta = (DisplayName = "Log Level", Keywords = "UE4logger log level", CompactNodeTitle = "Log Level")) enum ELogLevel { None = 0, @@ -44,31 +25,44 @@ class UUE4LoggerBPLibrary : public UBlueprintFunctionLibrary GENERATED_UCLASS_BODY() #pragma region verbosity - UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Set Log Level", Keywords = "UE4Logger log set verbosity level"), Category = "UE4-Logger|Log Level") + //Sets the log verbosity + //NOTE: This persists between Editor plays + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Set Log Level", Keywords = "UE4Logger log set verbosity level"), Category = "UE4-Logger|Verbosity") static void SetLogLevel(UObject * WorldContextObject, ELogLevel eLogLevel = ELogLevel::Error); - UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Get Log Level", Keywords = "UE4Logger log get verbosity level"), Category = "UE4-Logger|Log Level") + //Gets the log verbosity + //If logging is disabled it will return "None" + UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Get Log Level", Keywords = "UE4Logger log get verbosity level"), Category = "UE4-Logger|Verbosity") static ELogLevel GetLogLevel(UObject * WorldContextObject); - UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Is Log Level Suppressed", Keywords = "UE4Logger log is suppressed verbosity level"), Category = "UE4-Logger|Log Level") + //Checks if the specified log level is suppressed because of SetLogLevel + //Will always return True if logging is disabled + UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Is Log Level Suppressed", Keywords = "UE4Logger log is suppressed verbosity level"), Category = "UE4-Logger|Verbosity") static bool IsLogLevelSuppressed(UObject * WorldContextObject, ELogLevel eLogLevel = ELogLevel::Info); #pragma endregion #pragma region utility functions - UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Log Info", Keywords = "UE4Logger log info print", AdvancedDisplay = "2"), Category = "UE4-Logger") + //Logs a string with the Info log level + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Log Info", Keywords = "UE4Logger log info print", AdvancedDisplay = "2"), Category = "UE4-Logger|Utility Functions") static void LogInfo(UObject* WorldContextObject, FString InString = "Hello", bool bPrintToLog = true, bool bPrintToScreen = true, float Duration = 2.0f); - UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Log Warning", Keywords = "UE4Logger log warning print", AdvancedDisplay = "2"), Category = "UE4-Logger") + //Logs a string with the Warning log level + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Log Warning", Keywords = "UE4Logger log warning print", AdvancedDisplay = "2"), Category = "UE4-Logger|Utility Functions") static void LogWarning(UObject* WorldContextObject, FString InString = "Hello", bool bPrintToLog = true, bool bPrintToScreen = true, float Duration = 2.0f); - UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Log Error", Keywords = "UE4Logger log error print", AdvancedDisplay = "2"), Category = "UE4-Logger") + //Logs a string with the Error log level + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Log Error", Keywords = "UE4Logger log error print", AdvancedDisplay = "2"), Category = "UE4-Logger|Utility Functions") static void LogError(UObject* WorldContextObject, FString InString = "Hello", bool bPrintToLog = true, bool bPrintToScreen = true, float Duration = 2.0f); - UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Log Fatal (Crash Engine)", Keywords = "UE4Logger log fatal crash engine print", AdvancedDisplay = "2"), Category = "UE4-Logger|Advanced") - static void CrashEngine(UObject* WorldContextObject, FString Message = "Fatal Error"); + //Logs a string with the Fatal log level + //***CAUTION*** This crashes the engine! + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Log Fatal (Crash Engine)", Keywords = "UE4Logger log fatal crash engine print", AdvancedDisplay = "2"), Category = "UE4-Logger|Utility Functions") + static void LogFatal(UObject* WorldContextObject, FString Message = "Fatal Error"); #pragma endregion #pragma region generic function + //Logs a string + //The log level input can be changed at runtime UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext, DisplayName = "Log", Keywords = "UE4Logger log print string", AdvancedDisplay = "3"), Category = "UE4-Logger") static void Log(UObject* WorldContextObject, FString InString = "Hello", ELogLevel eLogLevel = ELogLevel::Info, bool bPrintToLog = true, bool bPrintToScreen = true, float Duration = 2.0f); #pragma endregion diff --git a/UE4Logger.uplugin b/UE4Logger.uplugin index 64d9b04..e29dd62 100644 --- a/UE4Logger.uplugin +++ b/UE4Logger.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 3, - "VersionName": "0.3", + "Version": 4, + "VersionName": "0.4", "FriendlyName": "UE4-Logger - Advanced Logging", "Description": "A plugin to add blueprint nodes for a better logging", "Category": "Blueprint",