From a0449ac2ca1e72cdc9725cb689c0ee6f748e2dfb Mon Sep 17 00:00:00 2001 From: Bartosz Cichecki Date: Sun, 6 Nov 2022 01:35:46 +0100 Subject: [PATCH] Log to debug while debugging --- LenovoLegionToolkit.Lib/Utils/Log.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/LenovoLegionToolkit.Lib/Utils/Log.cs b/LenovoLegionToolkit.Lib/Utils/Log.cs index 38b2464db9..c297c8d0d7 100644 --- a/LenovoLegionToolkit.Lib/Utils/Log.cs +++ b/LenovoLegionToolkit.Lib/Utils/Log.cs @@ -52,17 +52,6 @@ public void Trace(FormattableString message, LogInternal(_logPath, message, ex, file, lineNumber, caller); } - public void Debug(string fileName, - FormattableString message, - Exception? ex = null, - [CallerFilePath] string? file = null, - [CallerLineNumber] int lineNumber = -1, - [CallerMemberName] string? caller = null) - { - var logPath = Path.Combine(_folderPath, $"{fileName}.txt"); - LogInternal(logPath, message, ex, file, lineNumber, caller); - } - private void LogInternal(string path, FormattableString message, Exception? ex, @@ -78,6 +67,12 @@ private void LogInternal(string path, }; if (ex is not null) lines.Add(Serialize(ex)); + +#if DEBUG + foreach (var line in lines) + Debug.WriteLine(line); +#endif + File.AppendAllLines(path, lines); } }