Move CogLogCategory in common project

This commit is contained in:
Arnaud Jamin
2024-03-01 11:04:14 -05:00
parent 14ca7e035e
commit dd2c4ad694
14 changed files with 67 additions and 66 deletions
+2
View File
@@ -0,0 +1,2 @@
[CoreRedirects]
+StructRedirects=(OldName="/Script/CogDebug.CogLogCategory",NewName="/Script/CogCommon.CogLogCategory")
@@ -31,7 +31,7 @@ public class CogCommon : ModuleRules
new string[]
{
"CoreUObject",
"Engine",
"Engine", "CogDebug",
}
);
@@ -1,13 +1,11 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugLogCategory.generated.h"
struct FCogLogCategory;
#include "CogCommonLogCategory.generated.h"
//--------------------------------------------------------------------------------------------------------------------------
USTRUCT(BlueprintType)
struct COGDEBUG_API FCogLogCategory
struct COGCOMMON_API FCogLogCategory
{
GENERATED_USTRUCT_BODY()
@@ -18,9 +16,5 @@ struct COGDEBUG_API FCogLogCategory
FString GetName() const { return Name.ToString(); }
FLogCategoryBase* GetLogCategory() const;
private:
mutable FLogCategoryBase* LogCategory = nullptr;
};
@@ -1,13 +1,14 @@
#include "CogDebugDrawBlueprint.h"
#include "CogDebugDraw.h"
#include "CogDebugLogCategory.h"
#include "CogCommonLogCategory.h"
#include "CogDebugLog.h"
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugDrawBlueprint::DebugDrawString(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FString& Text, const FVector Location, const FLinearColor Color, const bool Persistent)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::String(*LogCategoryPtr, WorldContextObject, Text, Location, Color.ToFColor(true), Persistent);
}
@@ -18,7 +19,7 @@ void UCogDebugDrawBlueprint::DebugDrawString(const UObject* WorldContextObject,
void UCogDebugDrawBlueprint::DebugDrawPoint(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector Location, const float Size, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::Point(*LogCategoryPtr, WorldContextObject, Location, Size, Color.ToFColor(true), Persistent, DepthPriority);
}
@@ -29,7 +30,7 @@ void UCogDebugDrawBlueprint::DebugDrawPoint(const UObject* WorldContextObject, c
void UCogDebugDrawBlueprint::DebugDrawSegment(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::Segment(*LogCategoryPtr, WorldContextObject, SegmentStart, SegmentEnd, Color.ToFColor(true), Persistent, DepthPriority);
}
@@ -40,7 +41,7 @@ void UCogDebugDrawBlueprint::DebugDrawSegment(const UObject* WorldContextObject,
void UCogDebugDrawBlueprint::DebugDrawArrow(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::Arrow(*LogCategoryPtr, WorldContextObject, SegmentStart, SegmentEnd, Color.ToFColor(true), Persistent, DepthPriority);
}
@@ -51,7 +52,7 @@ void UCogDebugDrawBlueprint::DebugDrawArrow(const UObject* WorldContextObject, c
void UCogDebugDrawBlueprint::DebugDrawAxis(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector Location, const FRotator Rotation, const float Scale, const bool Persistent, const uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::Axis(*LogCategoryPtr, WorldContextObject, Location, Rotation, Scale, Persistent, DepthPriority);
}
@@ -62,7 +63,7 @@ void UCogDebugDrawBlueprint::DebugDrawAxis(const UObject* WorldContextObject, co
void UCogDebugDrawBlueprint::DebugDrawSphere(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector Location, const float Radius, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::Sphere(*LogCategoryPtr, WorldContextObject, Location, Radius, Color.ToFColor(true), Persistent, DepthPriority);
}
@@ -73,7 +74,7 @@ void UCogDebugDrawBlueprint::DebugDrawSphere(const UObject* WorldContextObject,
void UCogDebugDrawBlueprint::DebugDrawBox(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::Box(*LogCategoryPtr, WorldContextObject, Center, Extent, Rotation, Color.ToFColor(true), Persistent, DepthPriority);
}
@@ -84,7 +85,7 @@ void UCogDebugDrawBlueprint::DebugDrawBox(const UObject* WorldContextObject, con
void UCogDebugDrawBlueprint::DebugDrawSolidBox(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::SolidBox(*LogCategoryPtr, WorldContextObject, Center, Extent, Rotation, Color.ToFColor(true), Persistent, DepthPriority);
}
@@ -95,7 +96,7 @@ void UCogDebugDrawBlueprint::DebugDrawSolidBox(const UObject* WorldContextObject
void UCogDebugDrawBlueprint::DebugDrawCapsule(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector Center, const float HalfHeight, const float Radius, const FQuat Rotation, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::Capsule(*LogCategoryPtr, WorldContextObject, Center, HalfHeight, Radius, Rotation, Color.ToFColor(true), Persistent, DepthPriority);
}
@@ -106,7 +107,7 @@ void UCogDebugDrawBlueprint::DebugDrawCapsule(const UObject* WorldContextObject,
void UCogDebugDrawBlueprint::DebugDrawCircle(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FMatrix& Matrix, const float Radius, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::Circle(*LogCategoryPtr, WorldContextObject, Matrix, Radius, Color.ToFColor(true), Persistent, DepthPriority);
}
@@ -117,7 +118,7 @@ void UCogDebugDrawBlueprint::DebugDrawCircle(const UObject* WorldContextObject,
void UCogDebugDrawBlueprint::DebugDrawCircleArc(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FMatrix& Matrix, const float InnerRadius, const float OuterRadius, const float Angle, const FLinearColor Color, const bool Persistent, uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::CircleArc(*LogCategoryPtr, WorldContextObject, Matrix, InnerRadius, OuterRadius, Angle, Color.ToFColor(true), Persistent, DepthPriority);
}
@@ -128,7 +129,7 @@ void UCogDebugDrawBlueprint::DebugDrawCircleArc(const UObject* WorldContextObjec
void UCogDebugDrawBlueprint::DebugDrawPoints(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const TArray<FVector>& Points, const float Radius, const FLinearColor StartColor, const FLinearColor EndColor, const bool Persistent, const uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::Points(*LogCategoryPtr, WorldContextObject, Points, Radius, StartColor.ToFColor(true), EndColor.ToFColor(true), Persistent, DepthPriority);
}
@@ -139,7 +140,7 @@ void UCogDebugDrawBlueprint::DebugDrawPoints(const UObject* WorldContextObject,
void UCogDebugDrawBlueprint::DebugDrawPath(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const TArray<FVector>& Points, const float PointSize, const FLinearColor StartColor, const FLinearColor EndColor, const bool Persistent, const uint8 DepthPriority)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::Path(*LogCategoryPtr, WorldContextObject, Points, PointSize, StartColor.ToFColor(true), EndColor.ToFColor(true), Persistent, DepthPriority);
}
@@ -150,7 +151,7 @@ void UCogDebugDrawBlueprint::DebugDrawPath(const UObject* WorldContextObject, co
void UCogDebugDrawBlueprint::DebugDrawString2D(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FString& Text, const FVector2D Location, const FLinearColor Color, const bool Persistent)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::String2D(*LogCategoryPtr, WorldContextObject, Text, Location, Color.ToFColor(true), Persistent);
}
@@ -161,7 +162,7 @@ void UCogDebugDrawBlueprint::DebugDrawString2D(const UObject* WorldContextObject
void UCogDebugDrawBlueprint::DebugDrawSegment2D(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector2D SegmentStart, const FVector2D SegmentEnd, const FLinearColor Color, const bool Persistent)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::Segment2D(*LogCategoryPtr, WorldContextObject, SegmentStart, SegmentEnd, Color.ToFColor(true), Persistent);
}
@@ -172,7 +173,7 @@ void UCogDebugDrawBlueprint::DebugDrawSegment2D(const UObject* WorldContextObjec
void UCogDebugDrawBlueprint::DebugDrawCircle2D(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector2D Location, const float Radius, const FLinearColor Color, const bool Persistent)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::Circle2D(*LogCategoryPtr, WorldContextObject, Location, Radius, Color.ToFColor(true), Persistent);
}
@@ -183,7 +184,7 @@ void UCogDebugDrawBlueprint::DebugDrawCircle2D(const UObject* WorldContextObject
void UCogDebugDrawBlueprint::DebugDrawRect2D(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector2D Min, const FVector2D Max, const FLinearColor Color, const bool Persistent)
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
FCogDebugDraw::Rect2D(*LogCategoryPtr, WorldContextObject, Min, Max, Color.ToFColor(true), Persistent);
}
@@ -1,5 +1,6 @@
#include "CogDebugLog.h"
#include "CogCommonLogCategory.h"
#include "CogDebugModule.h"
#include "CogDebugReplicator.h"
#include "Engine/Engine.h"
@@ -149,3 +150,32 @@ void FCogDebugLog::DeactivateAllLogCategories(UWorld& World)
PlayerController->ServerExec(ToggleStr);
}
}
//--------------------------------------------------------------------------------------------------------------------------
FLogCategoryBase* FCogDebugLog::GetLogCategoryBase(const FCogLogCategory& LogCategory)
{
#if NO_LOGGING
return nullptr;
#else
if (LogCategory.Name.IsNone() || LogCategory.Name.IsValid() == false)
{
return nullptr;
}
if (LogCategory.LogCategory == nullptr)
{
if (const FCogDebugLogCategoryInfo* CategoryInfo = FCogDebugLog::GetLogCategories().Find(LogCategory.Name))
{
LogCategory.LogCategory = CategoryInfo->LogCategory;
}
}
return LogCategory.LogCategory;
#endif //NO_LOGGING
}
@@ -2,14 +2,14 @@
#include "CogCommon.h"
#include "CogDebugLog.h"
#include "CogDebugLogCategory.h"
#include "CogCommonLogCategory.h"
//--------------------------------------------------------------------------------------------------------------------------
void UCogDebugLogBlueprint::Log(const UObject* WorldContextObject, const FCogLogCategory LogCategory, ECogLogVerbosity Verbosity, const FString& Text)
{
#if ENABLE_COG
const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory();
const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory);
if (LogCategoryPtr == nullptr)
{
@@ -34,7 +34,7 @@ bool UCogDebugLogBlueprint::IsLogActive(const UObject* WorldContextObject, const
{
#if ENABLE_COG
if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory())
if (const FLogCategoryBase* LogCategoryPtr = FCogDebugLog::GetLogCategoryBase(LogCategory))
{
if (FCogDebugLog::IsLogCategoryActive(*LogCategoryPtr) == false)
{
@@ -1,31 +0,0 @@
#include "CogDebugLogCategory.h"
#include "CogDebugLog.h"
//--------------------------------------------------------------------------------------------------------------------------
FLogCategoryBase* FCogLogCategory::GetLogCategory() const
{
#if NO_LOGGING
return nullptr;
#else
if (Name.IsNone() || Name.IsValid() == false)
{
return nullptr;
}
if (LogCategory == nullptr)
{
if (const FCogDebugLogCategoryInfo* CategoryInfo = FCogDebugLog::GetLogCategories().Find(Name))
{
LogCategory = CategoryInfo->LogCategory;
}
}
return LogCategory;
#endif //NO_LOGGING
}
@@ -3,6 +3,8 @@
#include "CoreMinimal.h"
#include "Logging/LogVerbosity.h"
struct FCogLogCategory;
//--------------------------------------------------------------------------------------------------------------------------
DECLARE_LOG_CATEGORY_EXTERN(LogCogNone, Warning, All);
DECLARE_LOG_CATEGORY_EXTERN(LogCogServerDebug, Verbose, All);
@@ -38,6 +40,8 @@ struct COGDEBUG_API FCogDebugLog
static FLogCategoryBase* FindLogCategory(FName CategoryName);
static FLogCategoryBase* GetLogCategoryBase(const FCogLogCategory& LogCategory);
static FCogDebugLogCategoryInfo* FindLogCategoryInfo(FName CategoryName);
static TMap<FName, FCogDebugLogCategoryInfo>& GetLogCategories() { return LogCategories; }
@@ -24,6 +24,7 @@ public class CogDebugEditor : ModuleRules
new string[]
{
"AssetTools",
"CogCommon",
"CogDebug",
"EditorStyle",
"EditorWidgets",
@@ -1,6 +1,6 @@
#include "CogDebugLogCategoryDetails.h"
#include "CogDebugLogCategory.h"
#include "CogCommonLogCategory.h"
#include "CogDebugLog.h"
#include "DetailWidgetRow.h"
#include "Editor.h"
@@ -1,6 +1,6 @@
#include "SCogDebugLogCategoryGraphPin.h"
#include "CogDebugLogCategory.h"
#include "CogCommonLogCategory.h"
#include "ScopedTransaction.h"
#include "SCogDebugLogCategoryWidget.h"
#include "UObject/UObjectIterator.h"
@@ -2,7 +2,7 @@
#include "CoreMinimal.h"
#include "CogDebugGraphPanelPinFactory.h"
#include "CogDebugLogCategory.h"
#include "CogCommonLogCategory.h"
#include "EdGraphSchema_K2.h"
#include "EdGraphUtilities.h"
#include "SCogDebugLogCategoryGraphPin.h"
+1 -1
View File
@@ -7,7 +7,7 @@ public class CogSampleTarget : TargetRules
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V2;
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_2;
//IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_2;
ExtraModuleNames.Add("CogSample");
//bUseUnityBuild = false;
//bUsePCHFiles = false;
+1 -1
View File
@@ -7,7 +7,7 @@ public class CogSampleEditorTarget : TargetRules
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V2;
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_2;
//IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_2;
ExtraModuleNames.Add("CogSample");
}
}