using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IPA.Logging;
namespace IPA.Logging.Printers
{
///
/// Prints a pretty message to the console.
///
public class ColoredConsolePrinter : LogPrinter
{
Logger.LogLevel filter = Logger.LogLevel.All;
///
/// A filter for this specific printer.
///
public override Logger.LogLevel Filter { get => filter; set => filter = value; }
///
/// The color to print messages as.
///
public ConsoleColor Color { get; set; } = Console.ForegroundColor;
///
/// Prints an entry to the associated file.
///
/// the of the message
/// the the message was recorded at
/// the name of the log that sent the message
/// the message to print
public override void Print(Logger.Level level, DateTime time, string logName, string message)
{
if (((byte)level & (byte)StandardLogger.PrintFilter) == 0) return;
Console.ForegroundColor = Color;
foreach (var line in message.Split(new string[] { "\n", Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
Console.WriteLine(string.Format(Logger.LogFormat, line, logName, time, level.ToString().ToUpper()));
Console.ResetColor();
}
}
}