ErrorLogger

ErrorLogger
This commit is contained in:
ALEXTANG
2023-04-18 17:07:11 +08:00
parent c98cef4e1e
commit 033cd12bc8
5 changed files with 68 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6fca85e737d54de0a3ed4bd7e7836fa4
timeCreated: 1681807710

View File

@@ -0,0 +1,26 @@
using UnityEngine;
namespace GameLogic
{
public class ErrorLogger
{
public ErrorLogger()
{
Application.logMessageReceived += LogHandler;
}
~ErrorLogger()
{
Application.logMessageReceived -= LogHandler;
}
private void LogHandler(string condition, string stacktrace, LogType type)
{
if (type == LogType.Exception)
{
string des = $"客户端报错, \n#内容#---{condition} \n#位置#---{stacktrace}";
GameModule.UI.ShowUI<LogUI>(des);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9ccc9fc5faf14d93baec285acaa97907
timeCreated: 1681807720

View File

@@ -0,0 +1,33 @@
using UnityEngine.UI;
using TEngine;
namespace GameLogic
{
[Window(UILayer.System)]
class LogUI : UIWindow
{
#region
private Text m_textError;
private Button m_btnClose;
public override void ScriptGenerator()
{
m_textError = FindChildComponent<Text>("m_textError");
m_btnClose = FindChildComponent<Button>("m_btnClose");
m_btnClose.onClick.AddListener(OnClickCloseBtn);
}
#endregion
#region
private void OnClickCloseBtn()
{
Close();
}
#endregion
public override void OnRefresh()
{
m_textError.text = UserData.ToString();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: faa647c543e54de9b2d55e189aef0eff
timeCreated: 1681807986