From 7c559e58f7cbc1a270179a8b4ed64842bbac0897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Mon, 28 Nov 2022 11:04:53 +0100 Subject: [PATCH] Do not log to Trace in DEBUG --- CommonHelpers/Log.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/CommonHelpers/Log.cs b/CommonHelpers/Log.cs index 180af28..7dc5f77 100644 --- a/CommonHelpers/Log.cs +++ b/CommonHelpers/Log.cs @@ -4,12 +4,22 @@ namespace CommonHelpers { public static class Log { +#if DEBUG + private static bool LogToTrace = true; +#else + private static bool LogToTrace = false; +#endif + private static bool LogToConsole = Environment.UserInteractive; + public static void TraceLine(string format, params object?[] arg) { - String line = string.Format(format, arg); + if (!LogToTrace && !LogToConsole) + return; - Trace.WriteLine(line); - if (Environment.UserInteractive) + String line = string.Format(format, arg); + if (LogToTrace) + Trace.WriteLine(line); + if (LogToConsole) Console.WriteLine(line); } }