From a37ec16c432798a2be8bfa73aca3dda0722239fa Mon Sep 17 00:00:00 2001 From: "PUBNUB\\jakub.grzesiowski" Date: Thu, 13 Nov 2025 16:27:52 +0100 Subject: [PATCH 1/2] Add snippet for docs about adding multiple loggers --- .../Assets/Snippets/Logging/LoggingSample.cs | 69 ++++++++++++++++++- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs b/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs index ce0b0179..1da37252 100644 --- a/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs +++ b/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs @@ -5,8 +5,9 @@ using System; using System.Globalization; -public class LoggingSample -{ +public class LoggingSample { + protected static PNConfiguration pnConfiguration; + // snippet.custom_logger // A custom logger that logs information on Unity console. // Use can implement logger that can log information using log4Net or file etc. @@ -54,4 +55,68 @@ public static void EnableLogging() pubnub.RemoveLogger(customLogger); // snippet.end } + + //Dummy loggers for snippet + class PubnubFileLogger : IPubnubLogger { + public void Trace(string logMessage) { + throw new NotImplementedException(); + } + + public void Debug(string logMessage) { + throw new NotImplementedException(); + } + + public void Info(string logMessage) { + throw new NotImplementedException(); + } + + public void Warn(string logMessage) { + throw new NotImplementedException(); + } + + public void Error(string logMessage) { + throw new NotImplementedException(); + } + } + + class PubnubAnalyticsLogger : IPubnubLogger { + public void Trace(string logMessage) { + throw new NotImplementedException(); + } + + public void Debug(string logMessage) { + throw new NotImplementedException(); + } + + public void Info(string logMessage) { + throw new NotImplementedException(); + } + + public void Warn(string logMessage) { + throw new NotImplementedException(); + } + + public void Error(string logMessage) { + throw new NotImplementedException(); + } + } + + public static void SetMultipleLoggers() { + + // snippet.multiple_loggers + var pubnub = new Pubnub(pnConfiguration); + + // Add multiple loggers + var unityLogger = new UnityPubNubLogger(pubnub.InstanceId); + var fileLogger = new PubnubFileLogger(); + var analyticsLogger = new PubnubAnalyticsLogger(); + + pubnub.SetLogger(unityLogger); + pubnub.SetLogger(fileLogger); + pubnub.SetLogger(analyticsLogger); + + // To remove a custom logger + pubnub.RemoveLogger(fileLogger); + // snippet.end + } } \ No newline at end of file From 723cd5b0eda9080663dd6b33998fc26e91f8d241 Mon Sep 17 00:00:00 2001 From: Mateusz Wiktor <39187473+techwritermat@users.noreply.github.com> Date: Fri, 14 Nov 2025 09:30:48 +0100 Subject: [PATCH 2/2] add "disable logging" code snippet --- .../Assets/Snippets/Logging/LoggingSample.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs b/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs index 1da37252..4af2a31f 100644 --- a/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs +++ b/PubNubUnity/Assets/Snippets/Logging/LoggingSample.cs @@ -119,4 +119,18 @@ public static void SetMultipleLoggers() { pubnub.RemoveLogger(fileLogger); // snippet.end } + + public static void DisableLogging() { + + // snippet.disable_logging + var pubnubConfiguration = new PNConfiguration(new UserId("uniqueUserId")) + { + SubscribeKey = "[yourSubscribeKey]", + PublishKey = "[yourPublishKey]", + // To explicitly disable logging + LogLevel = PubnubLogLevel.None, + }; + var pubnub = new Pubnub(pubnubConfiguration); + // snippet.end + } } \ No newline at end of file