From 4bdeb26e743d7b951c38f197c201b901447d48db Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 13 Apr 2023 13:06:39 +0200 Subject: [PATCH] Add `NetworkReplicator::EnableLog` to optionally enable verbose logging of networking --- Source/Engine/Networking/NetworkReplicator.cpp | 8 +++----- Source/Engine/Networking/NetworkReplicator.h | 7 +++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/Engine/Networking/NetworkReplicator.cpp b/Source/Engine/Networking/NetworkReplicator.cpp index 7ab1a7c4f..0e989489a 100644 --- a/Source/Engine/Networking/NetworkReplicator.cpp +++ b/Source/Engine/Networking/NetworkReplicator.cpp @@ -29,12 +29,10 @@ #include "Engine/Threading/Threading.h" #include "Engine/Threading/ThreadLocal.h" -// Enables verbose logging for Network Replicator actions (dev-only) -#define NETWORK_REPLICATOR_DEBUG_LOG 0 - -#if NETWORK_REPLICATOR_DEBUG_LOG +#if !BUILD_RELEASE +bool NetworkReplicator::EnableLog = false; #include "Engine/Core/Log.h" -#define NETWORK_REPLICATOR_LOG(messageType, format, ...) LOG(messageType, format, ##__VA_ARGS__) +#define NETWORK_REPLICATOR_LOG(messageType, format, ...) if (NetworkReplicator::EnableLog) { LOG(messageType, format, ##__VA_ARGS__); } #else #define NETWORK_REPLICATOR_LOG(messageType, format, ...) #endif diff --git a/Source/Engine/Networking/NetworkReplicator.h b/Source/Engine/Networking/NetworkReplicator.h index 0957094d0..24cfddd97 100644 --- a/Source/Engine/Networking/NetworkReplicator.h +++ b/Source/Engine/Networking/NetworkReplicator.h @@ -34,6 +34,13 @@ API_CLASS(static, Namespace = "FlaxEngine.Networking") class FLAXENGINE_API Netw typedef void (*SerializeFunc)(void* instance, NetworkStream* stream, void* tag); public: +#if !BUILD_RELEASE + /// + /// Enables verbose logging of the networking runtime. Can be used to debug problems of missing RPC invoke or object replication issues. + /// + API_FIELD() static bool EnableLog; +#endif + /// /// Adds the network replication serializer for a given type. ///