Browse Source

Refactor debug logging methods to use Conditional attribute and remove preprocessor directives

textGamex 2 days ago
parent
commit
1630777c4d
1 changed files with 3 additions and 7 deletions
  1. 3 7
      src/PicView.Core/DebugTools/DebugHelper.cs

+ 3 - 7
src/PicView.Core/DebugTools/DebugHelper.cs

@@ -1,6 +1,4 @@
-#if DEBUG
-using System.Diagnostics;
-#endif
+using System.Diagnostics;
 using System.Globalization;
 
 namespace PicView.Core.DebugTools;
@@ -30,21 +28,19 @@ public static class DebugHelper
     /// }
     /// </code>
     /// </example>
+    [Conditional("DEBUG")]
     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)"/>
+    [Conditional("DEBUG")]
     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
     }
 }