StdOutLogListener.cs 540 B

1234567891011121314151617181920
  1. using BepInEx.Logging;
  2. using UnityInjector.ConsoleUtil;
  3. namespace BepInEx.Core.Logging
  4. {
  5. /// <summary>
  6. /// Logs entries to StdOut, for platforms that spawn a console instance and hijack the original output stream.
  7. /// </summary>
  8. public class StdOutLogListener : 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. ConsoleManager.StandardOutStream?.Write(log);
  14. }
  15. public void Dispose() { }
  16. }
  17. }