From 8d6ede992483adff89a438e3b27be01e3de1120b Mon Sep 17 00:00:00 2001 From: zxl Date: Wed, 13 Nov 2024 16:45:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?add=EF=BC=9A=E6=B7=BB=E5=8A=A0gf=E7=9A=84Lo?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/DemoGame/GameScript/Hotfix/Log.meta | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Assets/DemoGame/GameScript/Hotfix/Log.meta diff --git a/Assets/DemoGame/GameScript/Hotfix/Log.meta b/Assets/DemoGame/GameScript/Hotfix/Log.meta new file mode 100644 index 0000000..7724252 --- /dev/null +++ b/Assets/DemoGame/GameScript/Hotfix/Log.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 62447c4f1289487baf38165183f5ea3b +timeCreated: 1731487450 \ No newline at end of file -- 2.25.1 From 1613c994d1301bd964d61d2060d873c2c6ef5abe Mon Sep 17 00:00:00 2001 From: zxl Date: Wed, 13 Nov 2024 16:48:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?add=EF=BC=9A=E6=B7=BB=E5=8A=A0gf=E7=9A=84lo?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Hotfix/{Log.meta => GFLog.meta} | 0 .../Hotfix/GFLog/GameFrameworkLog.cs | 202 ++++++++++++++++++ .../Hotfix/GFLog/GameFrameworkLog.cs.meta | 11 + .../Hotfix/GFLog/GameFrameworkLogLevel.cs | 36 ++++ .../GFLog/GameFrameworkLogLevel.cs.meta | 11 + .../GameScript/Hotfix/GFLog/ILogHelper.cs | 24 +++ .../Hotfix/GFLog/ILogHelper.cs.meta | 11 + .../DemoGame/GameScript/Hotfix/GFLog/Log.cs | 174 +++++++++++++++ .../GameScript/Hotfix/GFLog/Log.cs.meta | 11 + 9 files changed, 480 insertions(+) rename Assets/DemoGame/GameScript/Hotfix/{Log.meta => GFLog.meta} (100%) create mode 100644 Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLog.cs create mode 100644 Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLog.cs.meta create mode 100644 Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLogLevel.cs create mode 100644 Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLogLevel.cs.meta create mode 100644 Assets/DemoGame/GameScript/Hotfix/GFLog/ILogHelper.cs create mode 100644 Assets/DemoGame/GameScript/Hotfix/GFLog/ILogHelper.cs.meta create mode 100644 Assets/DemoGame/GameScript/Hotfix/GFLog/Log.cs create mode 100644 Assets/DemoGame/GameScript/Hotfix/GFLog/Log.cs.meta diff --git a/Assets/DemoGame/GameScript/Hotfix/Log.meta b/Assets/DemoGame/GameScript/Hotfix/GFLog.meta similarity index 100% rename from Assets/DemoGame/GameScript/Hotfix/Log.meta rename to Assets/DemoGame/GameScript/Hotfix/GFLog.meta diff --git a/Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLog.cs b/Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLog.cs new file mode 100644 index 0000000..a048831 --- /dev/null +++ b/Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLog.cs @@ -0,0 +1,202 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZFramework +{ + public static partial class GameFrameworkLog + { + private static ILogHelper s_LogHelper = null; + + /// + /// 设置框架日志辅助器 + /// + /// + public static void SetLogHelper(ILogHelper logHelper) + { + s_LogHelper = logHelper; + } + + /// + /// 打印调试级别日志,用于记录调试类日志信息。 + /// + /// 日志内容。 + public static void Debug(object message) + { + if (s_LogHelper == null) + { + return; + } + s_LogHelper.Log(GameFrameworkLogLevel.Debug, message); + } + + /// + /// 打印调试级别日志,用于记录调试类日志信息。 + /// + /// 日志内容。 + public static void Debug(string message) + { + if (s_LogHelper == null) + { + return; + } + s_LogHelper.Log(GameFrameworkLogLevel.Debug, message); + } + + //暂时保留,有需要再来缝补 + //public static void Debug(string format,T arg) + //{ + // if (s_LogHelper==null) + // { + // return; + // } + // s_LogHelper.Log(GameFrameworkLogLevel.Debug, Utility.Text.Format(format, arg)); + //} + + + + /// + /// 打印信息级别日志,用于记录程序正常运行日志信息。 + /// + /// 日志内容。 + public static void Info(object message) + { + if (s_LogHelper == null) + { + return; + } + s_LogHelper.Log(GameFrameworkLogLevel.Info, message); + } + + /// + /// 打印信息级别日志,用于记录程序正常运行日志信息。 + /// + /// 日志内容。 + public static void Info(string message) + { + if (s_LogHelper == null) + { + return; + } + + s_LogHelper.Log(GameFrameworkLogLevel.Info, message); + } + + //暂时保留,有需要再来缝补 + ///// + ///// 打印信息级别日志,用于记录程序正常运行日志信息。 + ///// + ///// 日志参数的类型。 + ///// 日志格式。 + ///// 日志参数。 + //public static void Info(string format, T arg) + //{ + // if (s_LogHelper == null) + // { + // return; + // } + + // s_LogHelper.Log(GameFrameworkLogLevel.Info, Utility.Text.Format(format, arg)); + //} + + + + + + /// + /// 打印警告级别日志,建议在发生局部功能逻辑错误,但尚不会导致游戏崩溃或异常时使用。 + /// + /// + public static void Warning(object message) + { + if (s_LogHelper == null) + { + return; + } + s_LogHelper.Log(GameFrameworkLogLevel.Info, message); + } + + /// + /// 打印警告级别日志,建议在发生局部功能逻辑错误,但尚不会导致游戏崩溃或异常时使用。 + /// + /// 日志内容。 + public static void Warning(string message) + { + if (s_LogHelper == null) + { + return; + } + + s_LogHelper.Log(GameFrameworkLogLevel.Warning, message); + } + + + + + + + /// + /// 打印错误级别日志,建议在发生功能逻辑错误,但尚不会导致游戏崩溃或异常时使用。 + /// + /// 日志内容。 + public static void Error(object message) + { + if (s_LogHelper == null) + { + return; + } + + s_LogHelper.Log(GameFrameworkLogLevel.Error, message); + } + /// + /// 打印错误级别日志,建议在发生功能逻辑错误,但尚不会导致游戏崩溃或异常时使用。 + /// + /// 日志内容。 + public static void Error(string message) + { + if (s_LogHelper == null) + { + return; + } + + s_LogHelper.Log(GameFrameworkLogLevel.Error, message); + } + + + + + + + + /// + /// 打印严重错误级别日志,建议在发生严重错误,可能导致游戏崩溃或异常时使用,此时应尝试重启进程或重建游戏框架。 + /// + /// 日志内容。 + public static void Fatal(object message) + { + if (s_LogHelper == null) + { + return; + } + + s_LogHelper.Log(GameFrameworkLogLevel.Fatal, message); + } + + /// + /// 打印严重错误级别日志,建议在发生严重错误,可能导致游戏崩溃或异常时使用,此时应尝试重启进程或重建游戏框架。 + /// + /// 日志内容。 + public static void Fatal(string message) + { + if (s_LogHelper == null) + { + return; + } + + s_LogHelper.Log(GameFrameworkLogLevel.Fatal, message); + } + + } +} diff --git a/Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLog.cs.meta b/Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLog.cs.meta new file mode 100644 index 0000000..dcda3f0 --- /dev/null +++ b/Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLog.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 50be90d24e7e7e44c8bed52815de32e1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLogLevel.cs b/Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLogLevel.cs new file mode 100644 index 0000000..716a3a2 --- /dev/null +++ b/Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLogLevel.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZFramework +{ + public enum GameFrameworkLogLevel : byte + { + /// + /// 调试。 + /// + Debug = 0, + + /// + /// 信息。 + /// + Info, + + /// + /// 警告。 + /// + Warning, + + /// + /// 错误。 + /// + Error, + + /// + /// 严重错误。 + /// + Fatal + } +} diff --git a/Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLogLevel.cs.meta b/Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLogLevel.cs.meta new file mode 100644 index 0000000..a1c2ce1 --- /dev/null +++ b/Assets/DemoGame/GameScript/Hotfix/GFLog/GameFrameworkLogLevel.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dac4ce4d055272846a55b555e1d66530 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/DemoGame/GameScript/Hotfix/GFLog/ILogHelper.cs b/Assets/DemoGame/GameScript/Hotfix/GFLog/ILogHelper.cs new file mode 100644 index 0000000..4411ab0 --- /dev/null +++ b/Assets/DemoGame/GameScript/Hotfix/GFLog/ILogHelper.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZFramework +{ + public static partial class GameFrameworkLog + { + /// + /// 框架日志辅助器接口。 + /// + public interface ILogHelper + { + /// + /// 记录日志。 + /// + /// 游戏框架日志等级。 + /// 日志内容。 + void Log(GameFrameworkLogLevel level, object message); + } + } +} diff --git a/Assets/DemoGame/GameScript/Hotfix/GFLog/ILogHelper.cs.meta b/Assets/DemoGame/GameScript/Hotfix/GFLog/ILogHelper.cs.meta new file mode 100644 index 0000000..38a96ba --- /dev/null +++ b/Assets/DemoGame/GameScript/Hotfix/GFLog/ILogHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 973fffb170e74df418838cc2b5543f25 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/DemoGame/GameScript/Hotfix/GFLog/Log.cs b/Assets/DemoGame/GameScript/Hotfix/GFLog/Log.cs new file mode 100644 index 0000000..b7d9e60 --- /dev/null +++ b/Assets/DemoGame/GameScript/Hotfix/GFLog/Log.cs @@ -0,0 +1,174 @@ +using System; +using System.Diagnostics; + +namespace ZFramework.Runtime +{ + public static class Log + { + /// + /// 打印调试级别日志,用于记录调试类日志信息。 + /// + /// 日志内容。 + /// 仅在带有 ENABLE_LOG、ENABLE_DEBUG_LOG 或 ENABLE_DEBUG_AND_ABOVE_LOG 预编译选项时生效。 + [Conditional("ENABLE_LOG")] + [Conditional("ENABLE_DEBUG_LOG")] + [Conditional("ENABLE_DEBUG_AND_ABOVE_LOG")] + public static void Debug(object message) + { + GameFrameworkLog.Debug(message); + } + + /// + /// 打印调试级别日志,用于记录调试类日志信息。 + /// + /// 日志内容。 + /// 仅在带有 ENABLE_LOG、ENABLE_DEBUG_LOG 或 ENABLE_DEBUG_AND_ABOVE_LOG 预编译选项时生效。 + [Conditional("ENABLE_LOG")] + [Conditional("ENABLE_DEBUG_LOG")] + [Conditional("ENABLE_DEBUG_AND_ABOVE_LOG")] + public static void Debug(string message) + { + GameFrameworkLog.Debug(message); + } + + + + + + /// + /// 打印信息级别日志,用于记录程序正常运行日志信息。 + /// + /// 日志内容。 + /// 仅在带有 ENABLE_LOG、ENABLE_INFO_LOG、ENABLE_DEBUG_AND_ABOVE_LOG 或 ENABLE_INFO_AND_ABOVE_LOG 预编译选项时生效。 + [Conditional("ENABLE_LOG")] + [Conditional("ENABLE_INFO_LOG")] + [Conditional("ENABLE_DEBUG_AND_ABOVE_LOG")] + [Conditional("ENABLE_INFO_AND_ABOVE_LOG")] + public static void Info(object message) + { + GameFrameworkLog.Info(message); + } + + /// + /// 打印信息级别日志,用于记录程序正常运行日志信息。 + /// + /// 日志内容。 + /// 仅在带有 ENABLE_LOG、ENABLE_INFO_LOG、ENABLE_DEBUG_AND_ABOVE_LOG 或 ENABLE_INFO_AND_ABOVE_LOG 预编译选项时生效。 + [Conditional("ENABLE_LOG")] + [Conditional("ENABLE_INFO_LOG")] + [Conditional("ENABLE_DEBUG_AND_ABOVE_LOG")] + [Conditional("ENABLE_INFO_AND_ABOVE_LOG")] + public static void Info(string message) + { + GameFrameworkLog.Info(message); + } + + + + + + /// + /// 打印警告级别日志,建议在发生局部功能逻辑错误,但尚不会导致游戏崩溃或异常时使用。 + /// + /// 日志内容。 + /// 仅在带有 ENABLE_LOG、ENABLE_WARNING_LOG、ENABLE_DEBUG_AND_ABOVE_LOG、ENABLE_INFO_AND_ABOVE_LOG 或 ENABLE_WARNING_AND_ABOVE_LOG 预编译选项时生效。 + [Conditional("ENABLE_LOG")] + [Conditional("ENABLE_WARNING_LOG")] + [Conditional("ENABLE_DEBUG_AND_ABOVE_LOG")] + [Conditional("ENABLE_INFO_AND_ABOVE_LOG")] + [Conditional("ENABLE_WARNING_AND_ABOVE_LOG")] + public static void Warning(object message) + { + GameFrameworkLog.Warning(message); + } + + /// + /// 打印警告级别日志,建议在发生局部功能逻辑错误,但尚不会导致游戏崩溃或异常时使用。 + /// + /// 日志内容。 + /// 仅在带有 ENABLE_LOG、ENABLE_WARNING_LOG、ENABLE_DEBUG_AND_ABOVE_LOG、ENABLE_INFO_AND_ABOVE_LOG 或 ENABLE_WARNING_AND_ABOVE_LOG 预编译选项时生效。 + [Conditional("ENABLE_LOG")] + [Conditional("ENABLE_WARNING_LOG")] + [Conditional("ENABLE_DEBUG_AND_ABOVE_LOG")] + [Conditional("ENABLE_INFO_AND_ABOVE_LOG")] + [Conditional("ENABLE_WARNING_AND_ABOVE_LOG")] + public static void Warning(string message) + { + GameFrameworkLog.Warning(message); + } + + + + + + /// + /// 打印错误级别日志,建议在发生功能逻辑错误,但尚不会导致游戏崩溃或异常时使用。 + /// + /// 日志内容。 + /// 仅在带有 ENABLE_LOG、ENABLE_ERROR_LOG、ENABLE_DEBUG_AND_ABOVE_LOG、ENABLE_INFO_AND_ABOVE_LOG、ENABLE_WARNING_AND_ABOVE_LOG 或 ENABLE_ERROR_AND_ABOVE_LOG 预编译选项时生效。 + [Conditional("ENABLE_LOG")] + [Conditional("ENABLE_ERROR_LOG")] + [Conditional("ENABLE_DEBUG_AND_ABOVE_LOG")] + [Conditional("ENABLE_INFO_AND_ABOVE_LOG")] + [Conditional("ENABLE_WARNING_AND_ABOVE_LOG")] + [Conditional("ENABLE_ERROR_AND_ABOVE_LOG")] + public static void Error(object message) + { + GameFrameworkLog.Error(message); + } + + /// + /// 打印错误级别日志,建议在发生功能逻辑错误,但尚不会导致游戏崩溃或异常时使用。 + /// + /// 日志内容。 + /// 仅在带有 ENABLE_LOG、ENABLE_ERROR_LOG、ENABLE_DEBUG_AND_ABOVE_LOG、ENABLE_INFO_AND_ABOVE_LOG、ENABLE_WARNING_AND_ABOVE_LOG 或 ENABLE_ERROR_AND_ABOVE_LOG 预编译选项时生效。 + [Conditional("ENABLE_LOG")] + [Conditional("ENABLE_ERROR_LOG")] + [Conditional("ENABLE_DEBUG_AND_ABOVE_LOG")] + [Conditional("ENABLE_INFO_AND_ABOVE_LOG")] + [Conditional("ENABLE_WARNING_AND_ABOVE_LOG")] + [Conditional("ENABLE_ERROR_AND_ABOVE_LOG")] + public static void Error(string message) + { + GameFrameworkLog.Error(message); + } + + + + + + /// + /// 打印严重错误级别日志,建议在发生严重错误,可能导致游戏崩溃或异常时使用,此时应尝试重启进程或重建游戏框架。 + /// + /// 日志内容。 + /// 仅在带有 ENABLE_LOG、ENABLE_FATAL_LOG、ENABLE_DEBUG_AND_ABOVE_LOG、ENABLE_INFO_AND_ABOVE_LOG、ENABLE_WARNING_AND_ABOVE_LOG、ENABLE_ERROR_AND_ABOVE_LOG 或 ENABLE_FATAL_AND_ABOVE_LOG 预编译选项时生效。 + [Conditional("ENABLE_LOG")] + [Conditional("ENABLE_FATAL_LOG")] + [Conditional("ENABLE_DEBUG_AND_ABOVE_LOG")] + [Conditional("ENABLE_INFO_AND_ABOVE_LOG")] + [Conditional("ENABLE_WARNING_AND_ABOVE_LOG")] + [Conditional("ENABLE_ERROR_AND_ABOVE_LOG")] + [Conditional("ENABLE_FATAL_AND_ABOVE_LOG")] + public static void Fatal(object message) + { + GameFrameworkLog.Fatal(message); + } + + /// + /// 打印严重错误级别日志,建议在发生严重错误,可能导致游戏崩溃或异常时使用,此时应尝试重启进程或重建游戏框架。 + /// + /// 日志内容。 + /// 仅在带有 ENABLE_LOG、ENABLE_FATAL_LOG、ENABLE_DEBUG_AND_ABOVE_LOG、ENABLE_INFO_AND_ABOVE_LOG、ENABLE_WARNING_AND_ABOVE_LOG、ENABLE_ERROR_AND_ABOVE_LOG 或 ENABLE_FATAL_AND_ABOVE_LOG 预编译选项时生效。 + [Conditional("ENABLE_LOG")] + [Conditional("ENABLE_FATAL_LOG")] + [Conditional("ENABLE_DEBUG_AND_ABOVE_LOG")] + [Conditional("ENABLE_INFO_AND_ABOVE_LOG")] + [Conditional("ENABLE_WARNING_AND_ABOVE_LOG")] + [Conditional("ENABLE_ERROR_AND_ABOVE_LOG")] + [Conditional("ENABLE_FATAL_AND_ABOVE_LOG")] + public static void Fatal(string message) + { + GameFrameworkLog.Fatal(message); + } + } +} diff --git a/Assets/DemoGame/GameScript/Hotfix/GFLog/Log.cs.meta b/Assets/DemoGame/GameScript/Hotfix/GFLog/Log.cs.meta new file mode 100644 index 0000000..ada6e65 --- /dev/null +++ b/Assets/DemoGame/GameScript/Hotfix/GFLog/Log.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fc22ee3dac7343c4b930dd13598d98de +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: -- 2.25.1