36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using UnityEngine;
|
|
|
|
namespace GeneralTools
|
|
{
|
|
public class BroadcastDebug : SingletonBaseAttribute<BroadcastDebug>
|
|
{
|
|
SocketBase broadcastSender;
|
|
public override void IAwake()
|
|
{
|
|
base.IAwake();
|
|
if (ConfigHelper.broadcastDebug)
|
|
{
|
|
broadcastSender = SocketManager.Instance.CreateUdp(19527).SetSocketName("BroadcastDebugSocket").SetMsgEncoding(Encoding.GetEncoding("GB2312"));
|
|
Application.logMessageReceived += LogHandler;
|
|
}
|
|
}
|
|
public override void IOnApplicationQuit()
|
|
{
|
|
if (ConfigHelper.broadcastDebug)
|
|
{
|
|
Application.logMessageReceived -= LogHandler;
|
|
}
|
|
}
|
|
private void LogHandler(string condition, string stackTrace, LogType type)
|
|
{
|
|
var timeStr = DateTime.Now.ToString("HH:mm:ss.ff");
|
|
var logStr = string.Format("{0}-[{1}]{2}", timeStr, type, condition);
|
|
broadcastSender.SendMsg(logStr);
|
|
}
|
|
}
|
|
}
|