using UnityEngine; using System.Collections.Generic; using BingoBrain; public class ErrorLogger : MonoBehaviour { // 用于存储报错信息的列表 void OnEnable() { // 注册事件处理函数 Application.logMessageReceived += HandleLog; } void OnDisable() { // 注销事件处理函数 Application.logMessageReceived -= HandleLog; } // 事件处理函数 void HandleLog(string logString, string stackTrace, LogType type) { // 只处理错误和异常类型的日志 if (type == LogType.Error || type == LogType.Exception) { // 这里可以添加代码将报错信息发送给服务器 SendErrorToServer(logString, stackTrace, type); } } // 示例函数,展示如何将报错信息发送给服务器 void SendErrorToServer(string error, string stackTrace, LogType type) { // Debug.Log(error); // Debug.Log(stackTrace); GameHelper.SendLogToServer(error, stackTrace, type); // 这里填写将报错信息发送到服务器的代码 } } namespace DontConfuse { public class ErrorClass { public long uid; public string device; public string os_ver; public string network; public string device_id; public string pack_name; public string version; public string channel; public string level; public string message; public string stacktrace; } }