1
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using System.Diagnostics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.MyGame.Scripts.Net
|
||||
{
|
||||
/// <summary>
|
||||
/// 网络热路径日志封装。
|
||||
/// 用 [Conditional("ENABLE_VERBOSE_LOG")] 控制:
|
||||
/// - 默认不定义 ENABLE_VERBOSE_LOG → 编辑器和 Release 包都不输出,参数评估也被移除,零 GC
|
||||
/// - 需要调试时: Player Settings → Scripting Define Symbols 添加 ENABLE_VERBOSE_LOG
|
||||
/// 只用于 WebSocket 消息处理/出鱼等高频热路径,避免每帧/每消息产生日志 GC。
|
||||
/// </summary>
|
||||
public static class NetLog
|
||||
{
|
||||
[Conditional("ENABLE_VERBOSE_LOG")]
|
||||
public static void Log(string msg)
|
||||
{
|
||||
Debug.Log(msg);
|
||||
}
|
||||
|
||||
[Conditional("ENABLE_VERBOSE_LOG")]
|
||||
public static void Log(string prefix, string msg)
|
||||
{
|
||||
Debug.Log(prefix + msg);
|
||||
}
|
||||
|
||||
[Conditional("ENABLE_VERBOSE_LOG")]
|
||||
public static void LogWarning(string msg)
|
||||
{
|
||||
Debug.LogWarning(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user