public virtual string Color_LogLevel_Title(ELogLevel level, string name) { switch (level) { case ELogLevel.Trace: return(ANSI.White(name)); case ELogLevel.Info: case ELogLevel.Debug: return(ANSI.WhiteBright(name)); case ELogLevel.Success: return(ANSI.GreenBright(name)); case ELogLevel.Failure: return(ANSI.RedBright(name)); case ELogLevel.Warn: return(ANSI.YellowBright(name)); case ELogLevel.Error: return(ANSI.RedBright(name)); case ELogLevel.Assert: return(ANSI.MagentaBright(name)); case ELogLevel.Interface: return(ANSI.WhiteBright(name)); default: return(name); } }
public virtual string Color_LogLine(ELogLevel level, string msg) { switch (level) { case ELogLevel.Trace: return(ANSI.BlackBright(msg)); case ELogLevel.Info: case ELogLevel.Debug: return(ANSI.White(msg)); case ELogLevel.Success: return(ANSI.Green(msg)); case ELogLevel.Failure: return(ANSI.Red(msg)); case ELogLevel.Warn: return(ANSI.Yellow(msg)); case ELogLevel.Error: return(ANSI.Red(msg)); case ELogLevel.Assert: return(ANSI.Magenta(msg)); case ELogLevel.Interface: return(ANSI.White(msg)); default: return(msg); } }
private static void RunQueue() { while (Queue.TryDequeue(out LogLine line) != false) { try { if (!Settings.AllowColorCodes) { line.Text = ANSI.Strip(line.Text.AsMemory()); } // Consumer output if (line.Level >= Settings.LoggingLevel && line.Level != ELogLevel.Console)// NEVER write dummy lines to anything but an active console interface, not to file or to a log-network stream { string FormattedString = line.Text; // We test to make sure AllowColorCodes is true here to avoid performing the color strip twice. if (!Settings.AllowConsumerColorCodes && Settings.AllowColorCodes) { FormattedString = ANSI.Strip(FormattedString.AsMemory()); } foreach (ILogLineConsumer consumer in Consumers) { consumer.Consume(line); } } // Console output System.Diagnostics.Debug.WriteLine(line.Text); if (line.Level >= Settings.OutputLevel) { string Text = line.Text; if (!Settings.AllowColorCodes) { Text = ANSI.Strip(Text); } Terminal.WriteLine(Text.AsMemory()); } } catch (Exception ex) when(ex.InnerException != null) { ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); } } }