Parcourir la source

Wrap debug logging methods with `#if DEBUG` directive

- Added `#if DEBUG` guards around `LogDebug` methods to ensure debug logs are only generated in debug builds.
Ruben il y a 5 mois
Parent
commit
368493c1a5
1 fichiers modifiés avec 8 ajouts et 1 suppressions
  1. 8 1
      src/PicView.Core/DebugTools/DebugHelper.cs

+ 8 - 1
src/PicView.Core/DebugTools/DebugHelper.cs

@@ -1,4 +1,6 @@
-using System.Diagnostics;
+#if DEBUG
+using System.Diagnostics;
+#endif
 using System.Globalization;
 
 namespace PicView.Core.DebugTools;
@@ -30,14 +32,19 @@ public static class DebugHelper
     /// </example>
     public static void LogDebug(string className, string methodName, Exception exception)
     {
+#if DEBUG
         Debug.WriteLine(
             $"\n[{DateTime.Now.ToString("T", CultureInfo.CurrentCulture)}] {className}.{methodName} exception: {exception.Message}");
         Debug.WriteLine(exception.StackTrace + Environment.NewLine);
+#endif
     }
 
+    /// <inheritdoc cref="LogDebug(string,string,System.Exception)"/>
     public static void LogDebug(string className, string methodName, string exceptionMessage)
     {
+#if DEBUG
         Debug.WriteLine(
             $"\n[{DateTime.Now.ToString("T", CultureInfo.CurrentCulture)}] {className}.{methodName} exception: {exceptionMessage}");
+#endif
     }
 }