| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace DCL.LogReport |
| | 5 | | { |
| | 6 | | public class LogReportPlugin : IPlugin |
| | 7 | | { |
| 0 | 8 | | public LogReportPlugin() |
| | 9 | | { |
| 0 | 10 | | AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionCallback; |
| 0 | 11 | | Application.logMessageReceived += LogCallback; |
| 0 | 12 | | } |
| | 13 | |
|
| | 14 | | private void UnhandledExceptionCallback(object sender, UnhandledExceptionEventArgs e) |
| | 15 | | { |
| 0 | 16 | | if (e.ExceptionObject is Exception exception) |
| 0 | 17 | | LogReportKernelInterface.ReportLog("error", exception.Message); |
| 0 | 18 | | } |
| | 19 | |
|
| | 20 | | private void LogCallback(string condition, string stackTrace, LogType type) |
| | 21 | | { |
| 0 | 22 | | System.Diagnostics.StackTrace sTrace = new System.Diagnostics.StackTrace(); |
| 0 | 23 | | string message = $"{condition}\n{sTrace.ToString()}"; |
| | 24 | |
|
| 0 | 25 | | LogReportKernelInterface.ReportLog(type, message); |
| 0 | 26 | | } |
| | 27 | |
|
| | 28 | | public void Dispose() |
| | 29 | | { |
| 0 | 30 | | AppDomain.CurrentDomain.UnhandledException -= UnhandledExceptionCallback; |
| 0 | 31 | | Application.logMessageReceived -= LogCallback; |
| 0 | 32 | | } |
| | 33 | | } |
| | 34 | | } |