Improve file logging

This commit is contained in:
jvyden 2022-05-01 18:40:41 -04:00
parent 55160ff434
commit 1402bcfd65
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278

View file

@ -12,14 +12,12 @@ public class LighthouseFileLogger : ILogger
{
FileHelper.EnsureDirectoryCreated(logsDirectory);
string channel = string.IsNullOrEmpty(line.Area) ? "" : $"[{line.Area}] ";
string contentFile = $"{channel}{line.Message}\n";
string contentAll = $"[{$"{line.Level} {channel}".TrimEnd()}] {line.Message}\n";
string contentFile = $"[{line.Level}] <{line.Trace.Name}:{line.Trace.Section}> {line.Message}\n";
string contentAll = $"[{line.Area}:{line.Level}] <{line.Trace.Name}:{line.Trace.Section}> {line.Message}\n";
try
{
File.AppendAllText(Path.Combine(logsDirectory, line.Level + ".log"), contentFile);
File.AppendAllText(Path.Combine(logsDirectory, line.Area + ".log"), contentFile);
File.AppendAllText(Path.Combine(logsDirectory, "all.log"), contentAll);
}
catch(IOException) {} // windows, ya goofed