Web server mod for Techblox to run commands
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

35 Zeilen
1.0KB

  1. using System;
  2. using System.Threading.Tasks;
  3. using UnityEngine;
  4. using Object = UnityEngine.Object;
  5. namespace TBConsole
  6. {
  7. public class UnityLogHandler : ILogHandler
  8. {
  9. private readonly ILogHandler _original;
  10. private string _collectedLog = null;
  11. public UnityLogHandler(ILogHandler original) => _original = original;
  12. public void LogFormat(LogType logType, Object context, string format, params object[] args)
  13. {
  14. if (_collectedLog != null)
  15. _collectedLog += $"{logType} - {string.Format(format, args)} - {context}\n";
  16. _original.LogFormat(logType, context, format, args);
  17. }
  18. public void LogException(Exception exception, Object context)
  19. {
  20. _original.LogException(exception, context);
  21. }
  22. public void StartCollectingLogMessages() => _collectedLog = "";
  23. public string FinishCollectingLogMessages()
  24. {
  25. string ret = _collectedLog;
  26. _collectedLog = null;
  27. return ret;
  28. }
  29. }
  30. }