// Copyright 2025 https://yuewu.dev/en All Rights Reserved. #include "Utility/GMS_Log.h" #include "GameFramework/Actor.h" #include "Components/ActorComponent.h" #include "Animation/AnimInstance.h" const FName GMSLog::MessageLogName{TEXTVIEW("GMS")}; DEFINE_LOG_CATEGORY(LogGMS) DEFINE_LOG_CATEGORY(LogGMS_Animation) FString GetGMSLogContextString(const UObject* ContextObject) { ENetRole Role = ROLE_None; FString RoleName = TEXT("None"); FString Name = "None"; if (const AActor* Actor = Cast(ContextObject)) { Role = Actor->GetLocalRole(); Name = Actor->GetName(); } else if (const UActorComponent* Component = Cast(ContextObject)) { Role = Component->GetOwnerRole(); Name = Component->GetOwner()->GetName(); } else if (const UAnimInstance* AnimInstance = Cast(ContextObject)) { if (AnimInstance->GetOwningActor()) { Role = AnimInstance->GetOwningActor()->GetLocalRole(); Name = AnimInstance->GetOwningActor()->GetName(); } } else if (IsValid(ContextObject)) { Name = ContextObject->GetName(); } if (Role != ROLE_None) { RoleName = (Role == ROLE_Authority) ? TEXT("Server") : TEXT("Client"); } return FString::Printf(TEXT("[%s] (%s)"), *RoleName, *Name); }