/// <summary> /// Initializes a new instance of the ConsoleLogger class /// </summary> /// <param name="options"></param> public ConsoleLogger(ConsoleLoggerOptions options = ConsoleLoggerOptions.None) { _options = options; if (_options.HasFlag(ConsoleLoggerOptions.UseLabels)) { _successMarker = "[suc]"; _failureMarker = "[ftl]"; _actionMarker = "[act]"; _warningMarker = "[wrn]"; _informationMarker = "[inf]"; _detailMarker = "[dtl]"; _debugMarker = "[dbg]"; } if (options.HasFlag(ConsoleLoggerOptions.DisplayBanner)) { this.ConsoleBanner(); } }
private void WriteMessage(ConsoleColor color, string message) { var foreground = Console.ForegroundColor; try { if (_options.HasFlag(ConsoleLoggerOptions.ShowTime)) { Console.ForegroundColor = ConsoleColor.Gray; Console.Write($"[{DateTimeOffset.Now:HH:mm:ss.fff}] "); } Console.ForegroundColor = color; Console.WriteLine(message); } finally { Console.ForegroundColor = foreground; } }