Logger.cs 1.1 KB

123456789101112131415161718192021222324252627282930
  1. namespace BepInEx
  2. {
  3. /// <summary>
  4. /// A helper class to use for logging.
  5. /// </summary>
  6. public static class BepInLogger
  7. {
  8. /// <summary>
  9. /// The handler for a entry logged event.
  10. /// </summary>
  11. /// <param name="entry">The text element of the log itself.</param>
  12. /// <param name="show">Whether or not it should be dislpayed to the user.</param>
  13. public delegate void EntryLoggedEventHandler(string entry, bool show = false);
  14. /// <summary>
  15. /// The listener event for an entry being logged.
  16. /// </summary>
  17. public static event EntryLoggedEventHandler EntryLogged;
  18. /// <summary>
  19. /// Logs an entry to the logger, and any listeners are notified of the entry.
  20. /// </summary>
  21. /// <param name="entry">The text element of the log itself.</param>
  22. /// <param name="show">Whether or not it should be dislpayed to the user.</param>
  23. public static void Log(string entry, bool show = false)
  24. {
  25. EntryLogged?.Invoke(entry, show);
  26. }
  27. }
  28. }