mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-15 14:12:27 +00:00
* Abstract config design and update logging pattern Also drops legacy config support * Fix unit tests * Make backup of config file when upgrading * Use shared process semaphore to fix migration race conditions * Use mutex because semaphore isn't supported * Make startup wait for configs to load * Move mutex to config load instead of constructor * Add debug logging * Make mutex static * Change mutex name format * Make mutex use global namespace * Remove debug logging and fix config upgrading * Rename lambda variable
29 lines
No EOL
988 B
C#
29 lines
No EOL
988 B
C#
using System;
|
|
using LBPUnion.ProjectLighthouse.Extensions;
|
|
|
|
namespace LBPUnion.ProjectLighthouse.Logging.Loggers;
|
|
|
|
public class ConsoleLogger : ILogger
|
|
{
|
|
public void Log(LogLine logLine)
|
|
{
|
|
ConsoleColor oldForegroundColor = Console.ForegroundColor;
|
|
ConsoleColor logColor = logLine.Level.ToColor();
|
|
|
|
foreach (string line in logLine.Message.Split('\n'))
|
|
{
|
|
string time = DateTime.Now.ToString("MM/dd/yyyy-HH:mm:ss.fff");
|
|
string trace = "";
|
|
if (logLine.Trace.Name != null)
|
|
{
|
|
trace += logLine.Trace.Name;
|
|
if (logLine.Trace.Section != null) trace += ":" + logLine.Trace.Section;
|
|
trace = "[" + trace + "]";
|
|
}
|
|
|
|
Console.ForegroundColor = logColor;
|
|
Console.WriteLine(@$"[{time}] [{logLine.Area}/{logLine.Level.ToString().ToUpper()}] {trace}: {line}");
|
|
Console.ForegroundColor = oldForegroundColor;
|
|
}
|
|
}
|
|
} |