private void WriteBulk(string bulk, LogMessageClass c) { using (new ConsoleColorScope(GetForeground(c), GetBackground(c)).Enter()) { var outputStream = c == LogMessageClass.Error ? Console.Error : Console.Out; outputStream.Write(bulk); } }
protected virtual ConsoleColor?GetForeground(LogMessageClass messageClass) { switch (messageClass) { case LogMessageClass.Debug: return(ConsoleColor.DarkGray); case LogMessageClass.Warning: return(ConsoleColor.Yellow); case LogMessageClass.Error: return(ConsoleColor.Red); } return(null); }
private static string ClassToString(LogMessageClass @class) { switch (@class) { case LogMessageClass.Debug: return("DEBUG"); case LogMessageClass.Verbose: return("VERBOSE"); case LogMessageClass.Information: return("NOTICE"); case LogMessageClass.Warning: return("WARNING"); case LogMessageClass.Error: return("ERROR"); } return(null); }
public void Write(string message, LogMessageClass messageClass = LogMessageClass.Information) { Dispatch(new LogMessage { Text = message, Class = messageClass, Scope = MessageScope.State, Timestamp = DateTime.Now }); }
static void Main(string[] args) { CustomTimerClass ctc = new CustomTimerClass(); DisplayMessageClass dmc = new DisplayMessageClass (ctc); LogMessageClass lmc = new LogMessageClass (ctc); // Run the CustomTimerClass. ctc.Run(); Console.Write ("\nPress <ENTER> to end: "); Console.Read(); }
protected virtual ConsoleColor?GetBackground(LogMessageClass messageClass) => null;