using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DiscordRPC.Logging { /// /// Logs the outputs to the console using /// public class ConsoleLogger : ILogger { /// /// The level of logging to apply to this logger. /// public LogLevel Level { get; set; } /// /// Should the output be coloured? /// public bool Coloured { get; set; } /// /// A alias too /// public bool Colored { get { return Coloured; } set { Coloured = value; } } /// /// Creates a new instance of a Console Logger. /// public ConsoleLogger() { this.Level = LogLevel.Info; Coloured = false; } /// /// Creates a new instance of a Console Logger with a set log level /// /// /// public ConsoleLogger(LogLevel level, bool coloured = false) { Level = level; Coloured = coloured; } /// /// Informative log messages /// /// /// public void Trace(string message, params object[] args) { if (Level > LogLevel.Trace) return; if (Coloured) Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine("TRACE: " + message, args); } /// /// Informative log messages /// /// /// public void Info(string message, params object[] args) { if (Level > LogLevel.Info) return; if (Coloured) Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("INFO: " + message, args); } /// /// Warning log messages /// /// /// public void Warning(string message, params object[] args) { if (Level > LogLevel.Warning) return; if (Coloured) Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("WARN: " + message, args); } /// /// Error log messsages /// /// /// public void Error(string message, params object[] args) { if (Level > LogLevel.Error) return; if (Coloured) Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERR : " + message, args); } } }