You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.3 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace IPA.Logging.Printers
  7. {
  8. /// <summary>
  9. /// A colorless version of <see cref="ColoredConsolePrinter"/>, that indiscriminantly prints to standard out.
  10. /// </summary>
  11. public class ColorlessConsolePrinter : LogPrinter
  12. {
  13. /// <summary>
  14. /// A filter for this specific printer.
  15. /// </summary>
  16. public override Logger.LogLevel Filter { get; set; }
  17. /// <summary>
  18. /// Prints an entry to standard out.
  19. /// </summary>
  20. /// <param name="level">the <see cref="Logger.Level"/> of the message</param>
  21. /// <param name="time">the <see cref="DateTime"/> the message was recorded at</param>
  22. /// <param name="logName">the name of the log that sent the message</param>
  23. /// <param name="message">the message to print</param>
  24. public override void Print(Logger.Level level, DateTime time, string logName, string message)
  25. {
  26. if (((byte)level & (byte)StandardLogger.PrintFilter) == 0) return;
  27. foreach (var line in message.Split(new[] { "\n", Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
  28. Console.WriteLine(Logger.LogFormat, line, logName, time, level.ToString().ToUpper());
  29. }
  30. }
  31. }