UnityLogWriter.cs 860 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. namespace BepInEx.Logging
  4. {
  5. public class UnityLogWriter : BaseLogger
  6. {
  7. public void WriteToLog(string value)
  8. {
  9. UnityEngine.UnityLogWriter.WriteStringToUnityLog(value);
  10. }
  11. protected void InternalWrite(string value)
  12. {
  13. Console.Write(value);
  14. WriteToLog(value);
  15. }
  16. public override void WriteLine(string value) => InternalWrite($"{value}\r\n");
  17. public override void Write(char value) => InternalWrite(value.ToString());
  18. public override void Write(string value) => InternalWrite(value);
  19. }
  20. }
  21. namespace UnityEngine
  22. {
  23. internal sealed class UnityLogWriter
  24. {
  25. [MethodImpl(MethodImplOptions.InternalCall)]
  26. public static extern void WriteStringToUnityLog(string s);
  27. }
  28. }