From 69125e967f39de38dcb6d4c1931b797103e5588f Mon Sep 17 00:00:00 2001 From: huanggongming Date: Wed, 1 Mar 2023 16:10:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(YooLogger):=E6=94=AF=E6=8C=81=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=97=A5=E5=BF=97=E5=A4=84=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E6=96=B9=E4=BE=BF=E6=94=B6=E9=9B=86=E7=BA=BF=E4=B8=8A=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/YooAsset/Runtime/Utility/YooLogger.cs | 52 ++++++++++++++++++-- Assets/YooAsset/Runtime/YooAssets.cs | 9 ++++ 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/Assets/YooAsset/Runtime/Utility/YooLogger.cs b/Assets/YooAsset/Runtime/Utility/YooLogger.cs index c148a85..7668bc3 100644 --- a/Assets/YooAsset/Runtime/Utility/YooLogger.cs +++ b/Assets/YooAsset/Runtime/Utility/YooLogger.cs @@ -2,15 +2,38 @@ namespace YooAsset { + + public abstract class IYooLogger + { + public abstract void Info(string msg); + public abstract void Warning(string msg); + + public abstract void Error(string msg); + public abstract void Exception(System.Exception exception); + } + internal static class YooLogger { + + /// + /// 自定义日志处理 + /// + public static IYooLogger Logger = null; + /// /// 日志 /// [Conditional("DEBUG")] public static void Log(string info) { - UnityEngine.Debug.Log(info); + if (Logger != null) + { + Logger.Info(info); + } + else + { + UnityEngine.Debug.Log(info); + } } /// @@ -18,7 +41,14 @@ namespace YooAsset /// public static void Warning(string info) { - UnityEngine.Debug.LogWarning(info); + if (Logger != null) + { + Logger.Warning(info); + } + else + { + UnityEngine.Debug.LogWarning(info); + } } /// @@ -26,7 +56,14 @@ namespace YooAsset /// public static void Error(string info) { - UnityEngine.Debug.LogError(info); + if (Logger != null) + { + Logger.Error(info); + } + else + { + UnityEngine.Debug.LogError(info); + } } /// @@ -34,7 +71,14 @@ namespace YooAsset /// public static void Exception(System.Exception exception) { - UnityEngine.Debug.LogException(exception); + if (Logger != null) + { + Logger.Exception(exception); + } + else + { + UnityEngine.Debug.LogException(exception); + } } } } \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs index 466be01..a502a8c 100644 --- a/Assets/YooAsset/Runtime/YooAssets.cs +++ b/Assets/YooAsset/Runtime/YooAssets.cs @@ -184,6 +184,15 @@ namespace YooAsset DownloadSystem.CertificateHandlerInstance = instance; } + /// + /// 自定义日志处理 + /// + /// + public static void SetLogger(IYooLogger logger) + { + YooLogger.Logger = logger; + } + /// /// 设置下载系统参数,自定义下载请求 ///