1
0

Logger.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Text;
  6. using UnityInjector.ConsoleUtil;
  7. namespace Util
  8. {
  9. internal class LogLevel
  10. {
  11. public static LogLevel Info = new LogLevel(ConsoleColor.White, "INF");
  12. public static LogLevel Debug = new LogLevel(ConsoleColor.Gray, "DBG");
  13. public static LogLevel Warning = new LogLevel(ConsoleColor.Yellow, "WRN");
  14. public static LogLevel Error = new LogLevel(ConsoleColor.Red, "ERR");
  15. public ConsoleColor Color { get; }
  16. public string Tag { get; }
  17. private LogLevel(ConsoleColor color, string tag)
  18. {
  19. Color = color;
  20. Tag = tag;
  21. }
  22. }
  23. internal static class Logger
  24. {
  25. public const string PRE_TAG = "MultipleMaids";
  26. public static void Log(LogLevel level, string msg)
  27. {
  28. SafeConsole.ForegroundColor = level.Color;
  29. Console.WriteLine($"[{PRE_TAG}][{level.Tag}] {msg}");
  30. SafeConsole.ForegroundColor = ConsoleColor.White;
  31. }
  32. [Conditional("DEBUG")]
  33. public static void Debug(string msg)
  34. {
  35. Log(LogLevel.Debug, msg);
  36. }
  37. }
  38. }