using UnityEngine; namespace Neatly.Module { public class LogModule : ModuleSingleton { private static string m_ReceiveUrl = ""; private bool m_IsDevelop; public override void Init() { Application.logMessageReceived += HandleLog; } private void HandleLog(string logString, string stackTrace, LogType type) { if (m_IsDevelop) { if (type == LogType.Error||type==LogType.Exception||type==LogType.Assert) { //打开报错页面 } } if (string.IsNullOrEmpty(m_ReceiveUrl)) { return; } DevelopLog(logString, stackTrace, type); } private void DevelopLog(string logString, string stackTrace, LogType type) { string result = string.Format("{0}|类型:{1} LogString:{2}\n", Application.identifier, type, logString); ReportLog(result); } private void ReportLog(string msg) { HttpModule.Instance.PostJson(m_ReceiveUrl, "", msg, null); } public void SetIsDevelop(bool isDevelop) { m_IsDevelop = isDevelop; } public void SetReceiveUrl(string url) { m_ReceiveUrl = url; } } }