From a507df5f300d6b598cdcd649ddd88ef041b10d66 Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Sat, 27 Mar 2021 03:05:32 +0800 Subject: [PATCH] Debug Level Log --- Netch/Models/LogLevel.cs | 3 ++- Netch/Utils/Logging.cs | 8 ++++++++ Netch/Utils/Utils.cs | 4 +--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Netch/Models/LogLevel.cs b/Netch/Models/LogLevel.cs index 760ce5df..8d8e4f8f 100644 --- a/Netch/Models/LogLevel.cs +++ b/Netch/Models/LogLevel.cs @@ -4,6 +4,7 @@ namespace Netch.Models { INFO, WARNING, - ERROR + ERROR, + DEBUG } } \ No newline at end of file diff --git a/Netch/Utils/Logging.cs b/Netch/Utils/Logging.cs index d62b77c3..883197e3 100644 --- a/Netch/Utils/Logging.cs +++ b/Netch/Utils/Logging.cs @@ -43,6 +43,7 @@ namespace Netch.Utils #if DEBUG switch (logLevel) { + case LogLevel.DEBUG: case LogLevel.INFO: case LogLevel.WARNING: Console.Write(contents); @@ -56,6 +57,13 @@ namespace Netch.Utils #else lock (FileLock) File.AppendAllText(LogFile, contents); +#endif + } + + public static void Debug(string s) + { +#if DEBUG + Write(s, LogLevel.DEBUG); #endif } } diff --git a/Netch/Utils/Utils.cs b/Netch/Utils/Utils.cs index eb771202..bd89deb0 100644 --- a/Netch/Utils/Utils.cs +++ b/Netch/Utils/Utils.cs @@ -240,9 +240,7 @@ namespace Netch.Utils } }; -#if DEBUG - Console.WriteLine($"{fileName} {arguments}"); -#endif + Logging.Debug($"{fileName} {arguments}"); p.Start(); var output = await p.StandardOutput.ReadToEndAsync();