Skip to content

Commit

Permalink
added node description and fixed compilation for all the targets wher…
Browse files Browse the repository at this point in the history
…e logging is disabled
  • Loading branch information
yatima1460 committed Sep 23, 2017
1 parent fa5fb70 commit 93a9c9d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 35 deletions.
11 changes: 6 additions & 5 deletions Source/UE4Logger/Private/UE4LoggerBPLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
Expand All @@ -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)
{
Expand Down Expand Up @@ -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))
{
Expand Down
50 changes: 22 additions & 28 deletions Source/UE4Logger/Public/UE4LoggerBPLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,7 @@
#include <LogMacros.h>
#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,
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions UE4Logger.uplugin
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 93a9c9d

Please sign in to comment.