internal static void Commit(LogEntryType type, string message, string details, bool showUser) { if (type == LogEntryType.Debug && !Debugging) { return; } if (type != LogEntryType.Information || (type == LogEntryType.Information && !showUser)) { switch (type) { case LogEntryType.Error: ConsoleCrayon.ForegroundColor = ConsoleColor.Red; break; case LogEntryType.Warning: ConsoleCrayon.ForegroundColor = ConsoleColor.DarkYellow; break; case LogEntryType.Information: ConsoleCrayon.ForegroundColor = ConsoleColor.Green; break; case LogEntryType.Debug: ConsoleCrayon.ForegroundColor = ConsoleColor.Blue; break; } var thread_name = String.Empty; if (Debugging) { var thread = Thread.CurrentThread; thread_name = String.Format("{0} ", thread.ManagedThreadId); } Console.Write("[{5}{0} {1:00}:{2:00}:{3:00}.{4:000}]", TypeString(type), DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond, thread_name); ConsoleCrayon.ResetColor(); if (details != null) { Console.WriteLine(" {0} - {1}", message, details); } else { Console.WriteLine(" {0}", message); } } if (showUser) { OnNotify(new LogEntry(type, message, details)); } }
public static void Commit(LogEntryType type, string message, string details, bool showUser) { if (type == LogEntryType.Debug && !Debugging) { return; } if (type != LogEntryType.Information || (type == LogEntryType.Information && !showUser)) { switch (type) { case LogEntryType.Error: ConsoleCrayon.ForegroundColor = ConsoleColor.Red; break; case LogEntryType.Warning: ConsoleCrayon.ForegroundColor = ConsoleColor.DarkYellow; break; case LogEntryType.Information: ConsoleCrayon.ForegroundColor = ConsoleColor.Green; break; case LogEntryType.Debug: ConsoleCrayon.ForegroundColor = ConsoleColor.Blue; break; } var thread_name = string.Empty; if (Debugging) { var thread = Thread.CurrentThread; thread_name = $"{thread.ManagedThreadId} "; } Console.Write($"[{thread_name}{TypeString (type)} {DateTime.Now.Hour:00}:{DateTime.Now.Minute:00}:{DateTime.Now.Second:00}.{DateTime.Now.Millisecond:000}]"); ConsoleCrayon.ResetColor(); if (details != null) { Console.WriteLine($" {message} - {details}"); } else { Console.WriteLine($" {message}"); } } if (showUser) { OnNotify(new LogEntry(type, message, details)); } }