/// <summary> /// Initializes a new instance of the <see cref="ConsoleLoggingColors"/> class. /// </summary> public ConsoleLoggingColors() { Debug = ConsoleColorSetting.Foreground(ConsoleColor.Gray); Info = ConsoleColorSetting.Foreground(ConsoleColor.Green); Warn = ConsoleColorSetting.Foreground(ConsoleColor.Yellow); Error = ConsoleColorSetting.Foreground(ConsoleColor.Red); }
/// <summary> /// Initializes a new instance of the <see cref="ConsoleColorContext"/> class. /// </summary> /// <param name="colorSetting"> /// The color setting. /// </param> public ConsoleColorContext(ConsoleColorSetting colorSetting) { if (colorSetting.BackgroundColor.HasValue) { Console.BackgroundColor = colorSetting.BackgroundColor.Value; } Console.ForegroundColor = colorSetting.ForegroundColor; }
/// <summary> /// Log the specified message. /// </summary> /// <param name="level"> /// The level. /// </param> /// <param name="message"> /// The message. /// </param> /// <param name="colorSetting"> /// The color setting. /// </param> /// <param name="parameters"> /// The parameters. /// </param> private void Log(LogLevel level, string message, ConsoleColorSetting colorSetting, params object[] parameters) { if (_factory.Colored) { using (colorSetting.Enter()) { Write(level, message, parameters); } } else { Write(level, message, parameters); } }
/// <summary> /// Sets the foreground color to the specified color. /// </summary> /// <param name="foregroundColor"> /// The foreground color. /// </param> /// <returns> /// The color setting. /// </returns> public static ConsoleColorSetting Foreground(ConsoleColor foregroundColor) { var colorSettings = new ConsoleColorSetting(foregroundColor); return(colorSettings); }