|
- using System;
- using System.Threading.Tasks;
- using UnityEngine;
- using Object = UnityEngine.Object;
-
- namespace TBConsole
- {
- public class UnityLogHandler : ILogHandler
- {
- private readonly ILogHandler _original;
- private string _collectedLog = null;
- public UnityLogHandler(ILogHandler original) => _original = original;
-
- public void LogFormat(LogType logType, Object context, string format, params object[] args)
- {
- if (_collectedLog != null)
- _collectedLog += $"{logType} - {string.Format(format, args)} - {context}\n";
- _original.LogFormat(logType, context, format, args);
- }
-
- public void LogException(Exception exception, Object context)
- {
- _original.LogException(exception, context);
- }
-
- public void StartCollectingLogMessages() => _collectedLog = "";
-
- public string FinishCollectingLogMessages()
- {
- string ret = _collectedLog;
- _collectedLog = null;
- return ret;
- }
- }
- }
|