LoginSignup
1
0

More than 3 years have passed since last update.

UnityのExceptionのStackTraceをサーバなどに送りたい

Posted at

ILogHandlerで頑張るのかなと思ったら、Application.logMessageReceivedのほうで取れるらしいのですね。

LogReporter.cs
using System;
using UniRx.Async;
using UnityEngine;

namespace Tonari.Unity.LogSystem
{
    public class LogReporter : IDisposable
    {
        public LogReporter()
        {
            Application.logMessageReceived += LogCallBackHandler;
        }

        public void Dispose()
        {
            Application.logMessageReceived -= LogCallBackHandler;
        }

        private void LogCallBackHandler(string condition, string stackTrace, LogType logType)
        {
            ReportLogAsync(condition, stackTrace, logType).Forget();
        }

        private UniTask ReportLogAsync(string condition, string stackTrace, LogType logType)
        {
            // ここでサーバに送ればいい

            return UniTask.CompletedTask;
        }
    }
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0