using System; namespace ExtremelySimpleLogger { /// /// A that writes log output to . /// public class ConsoleSink : Sink { /// /// The that this console sink should use when printing messages with the log level. /// public ConsoleColor WarnColor { get; set; } = ConsoleColor.DarkYellow; /// /// The that this console sink should use when printing messages with the and log levels. /// public ConsoleColor ErrorColor { get; set; } = ConsoleColor.DarkRed; private readonly object locker = new object(); /// /// Logs the given message, which has already been formatted using . /// /// The logger that the message was passed to /// The importance level of this message /// The message to log protected override void Log(Logger logger, LogLevel level, string s) { lock (this.locker) { switch (level) { case LogLevel.Warn: Console.ForegroundColor = this.WarnColor; break; case LogLevel.Error: case LogLevel.Fatal: Console.ForegroundColor = this.ErrorColor; break; } Console.WriteLine(s); Console.ResetColor(); } } } }