Skip to content

Commit

Permalink
Log to debug while debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
BartoszCichecki committed Nov 6, 2022
1 parent 91cc27f commit a0449ac
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions LenovoLegionToolkit.Lib/Utils/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
}
Expand Down

0 comments on commit a0449ac

Please sign in to comment.