BepInLogger.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using BepInEx.Logging;
  3. namespace BepInEx
  4. {
  5. /// <summary>
  6. /// A helper class to use for logging.
  7. /// </summary>
  8. [Obsolete("This class has been deprecated; please use the Logger static class and BaseLogger implementations", true)]
  9. public static class BepInLogger
  10. {
  11. /// <summary>
  12. /// The handler for a entry logged event.
  13. /// </summary>
  14. /// <param name="entry">The text element of the log itself.</param>
  15. /// <param name="show">Whether or not it should be dislpayed to the user.</param>
  16. public delegate void EntryLoggedEventHandler(string entry, bool show = false);
  17. /// <summary>
  18. /// The listener event for an entry being logged.
  19. /// </summary>
  20. public static event EntryLoggedEventHandler EntryLogged;
  21. /// <summary>
  22. /// Logs an entry to the logger, and any listeners are notified of the entry.
  23. /// </summary>
  24. /// <param name="entry">The text element of the log itself.</param>
  25. /// <param name="show">Whether or not it should be dislpayed to the user.</param>
  26. public static void Log(string entry, bool show = false)
  27. {
  28. Logger.Log(show ? LogLevel.Message : LogLevel.Info, entry);
  29. EntryLogged?.Invoke(entry, show);
  30. }
  31. /// <summary>
  32. /// Logs an entry to the logger, and any listeners are notified of the entry.
  33. /// </summary>
  34. /// <param name="entry">The text element of the log itself. Uses .ToString().</param>
  35. /// <param name="show">Whether or not it should be dislpayed to the user.</param>
  36. /// <param name="color">The color of the text to show in the console.</param>
  37. public static void Log(object entry, bool show, ConsoleColor color)
  38. {
  39. Log(entry.ToString(), show);
  40. }
  41. /// <summary>
  42. /// Logs an entry to the logger, and any listeners are notified of the entry.
  43. /// </summary>
  44. /// <param name="entry">The text element of the log itself.</param>
  45. /// <param name="show">Whether or not it should be dislpayed to the user.</param>
  46. /// <param name="color">The color of the text to show in the console.</param>
  47. public static void Log(string entry, bool show, ConsoleColor color)
  48. {
  49. Log(entry, show);
  50. }
  51. }
  52. }