// Copyright 2025 https://yuewu.dev/en All Rights Reserved. #include "GIPS_LogChannels.h" #include "GameFramework/Actor.h" #include "Components/ActorComponent.h" DEFINE_LOG_CATEGORY(LogGIPS); FString GetGIPSLogContextString(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 (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); }