ConsoleLogListener.cs 537 B

12345678910111213141516171819202122
  1. using System;
  2. using BepInEx.ConsoleUtil;
  3. namespace BepInEx.Logging
  4. {
  5. /// <summary>
  6. /// Logs entries using Unity specific outputs.
  7. /// </summary>
  8. public class ConsoleLogListener : ILogListener
  9. {
  10. public void LogEvent(object sender, LogEventArgs eventArgs)
  11. {
  12. string log = $"[{eventArgs.Level, -7}:{((ILogSource)sender).SourceName, 10}] {eventArgs.Data}\r\n";
  13. Kon.ForegroundColor = eventArgs.Level.GetConsoleColor();
  14. Console.Write(log);
  15. Kon.ForegroundColor = ConsoleColor.Gray;
  16. }
  17. public void Dispose() { }
  18. }
  19. }