diff --git a/GFramework.Core.Abstractions/Directory.Build.props b/GFramework.Core.Abstractions/Directory.Build.props index 638b238..1e6c3bf 100644 --- a/GFramework.Core.Abstractions/Directory.Build.props +++ b/GFramework.Core.Abstractions/Directory.Build.props @@ -1,12 +1,16 @@  - + - net8.0;net9.0;net10.0 + netstandard2.0 true true + preview - all diff --git a/GFramework.Core.Abstractions/logging/ILogger.cs b/GFramework.Core.Abstractions/logging/ILogger.cs index ee0944d..185d604 100644 --- a/GFramework.Core.Abstractions/logging/ILogger.cs +++ b/GFramework.Core.Abstractions/logging/ILogger.cs @@ -1,18 +1,10 @@ -using System; -using GFramework.Core.logging; - -namespace GFramework.Core.Abstractions.logging; +namespace GFramework.Core.Abstractions.logging; /// /// 定义日志记录接口,提供日志记录和级别检查功能 /// public interface ILogger { - /// - /// 根日志记录器的名称常量 - /// - public const string RootLoggerName = "ROOT"; - /// /// 获取日志记录器的名称 /// @@ -62,19 +54,7 @@ public interface ILogger /// /// 要检查的日志级别 /// 如果指定的日志级别已启用则返回true,否则返回false - bool IsEnabledForLevel(LogLevel level) - { - return level switch - { - LogLevel.Trace => IsTraceEnabled(), - LogLevel.Debug => IsDebugEnabled(), - LogLevel.Info => IsInfoEnabled(), - LogLevel.Warning => IsWarnEnabled(), - LogLevel.Error => IsErrorEnabled(), - LogLevel.Fatal => IsFatalEnabled(), - _ => throw new ArgumentException($"Level [{level}] not recognized.", nameof(level)) - }; - } + bool IsEnabledForLevel(LogLevel level); #endregion diff --git a/GFramework.Core.Abstractions/logging/LogLevel.cs b/GFramework.Core.Abstractions/logging/LogLevel.cs index 1bced4e..9f70f89 100644 --- a/GFramework.Core.Abstractions/logging/LogLevel.cs +++ b/GFramework.Core.Abstractions/logging/LogLevel.cs @@ -1,4 +1,4 @@ -namespace GFramework.Core.logging; +namespace GFramework.Core.Abstractions.logging; /// /// 定义日志级别的枚举,用于标识不同严重程度的日志消息 diff --git a/GFramework.Core/logging/AbstractLogger.cs b/GFramework.Core/logging/AbstractLogger.cs index 68d9470..35e9153 100644 --- a/GFramework.Core/logging/AbstractLogger.cs +++ b/GFramework.Core/logging/AbstractLogger.cs @@ -1,6 +1,4 @@ -using GFramework.Core.Abstractions.logging; - -namespace GFramework.Core.logging; +namespace GFramework.Core.logging; /// /// 日志抽象基类,封装日志级别判断、格式化与异常处理逻辑。 @@ -10,7 +8,12 @@ public abstract class AbstractLogger( string? name = null, LogLevel minLevel = LogLevel.Info) : ILogger { - private readonly string _name = name ?? ILogger.RootLoggerName; + /// + /// 根日志记录器的名称常量 + /// + public const string RootLoggerName = "ROOT"; + + private readonly string _name = name ?? RootLoggerName; #region Metadata @@ -99,6 +102,27 @@ public abstract class AbstractLogger( return IsEnabled(LogLevel.Fatal); } + /// + /// 检查指定日志级别是否启用 + /// + /// 要检查的日志级别 + /// 如果指定级别启用返回true,否则返回false + /// 当传入的日志级别不被识别时抛出 + public bool IsEnabledForLevel(LogLevel level) + { + // 根据不同的日志级别调用对应的检查方法 + return level switch + { + LogLevel.Trace => IsTraceEnabled(), + LogLevel.Debug => IsDebugEnabled(), + LogLevel.Info => IsInfoEnabled(), + LogLevel.Warning => IsWarnEnabled(), + LogLevel.Error => IsErrorEnabled(), + LogLevel.Fatal => IsFatalEnabled(), + _ => throw new ArgumentException($"Level [{level}] not recognized.", nameof(level)) + }; + } + #endregion #region Trace diff --git a/GFramework.Godot.SourceGenerators.Abstractions/Directory.Build.props b/GFramework.Godot.SourceGenerators.Abstractions/Directory.Build.props index daa5255..82f43af 100644 --- a/GFramework.Godot.SourceGenerators.Abstractions/Directory.Build.props +++ b/GFramework.Godot.SourceGenerators.Abstractions/Directory.Build.props @@ -1,12 +1,16 @@ - + - net8.0;net9.0;net10.0 + netstandard2.0 true true + preview - all diff --git a/GFramework.Godot.SourceGenerators/GFramework.Godot.SourceGenerators.csproj b/GFramework.Godot.SourceGenerators/GFramework.Godot.SourceGenerators.csproj index c59cbc1..d0c2e31 100644 --- a/GFramework.Godot.SourceGenerators/GFramework.Godot.SourceGenerators.csproj +++ b/GFramework.Godot.SourceGenerators/GFramework.Godot.SourceGenerators.csproj @@ -2,7 +2,7 @@ GeWuYou.GFramework.Godot.SourceGenerators - net8.0;net9.0;net10.0 + netstandard2.0 true diff --git a/GFramework.SourceGenerators.Abstractions/Directory.Build.props b/GFramework.SourceGenerators.Abstractions/Directory.Build.props index daa5255..82f43af 100644 --- a/GFramework.SourceGenerators.Abstractions/Directory.Build.props +++ b/GFramework.SourceGenerators.Abstractions/Directory.Build.props @@ -1,12 +1,16 @@ - + - net8.0;net9.0;net10.0 + netstandard2.0 true true + preview - all diff --git a/GFramework.SourceGenerators.Common/Directory.Build.props b/GFramework.SourceGenerators.Common/Directory.Build.props index daa5255..82f43af 100644 --- a/GFramework.SourceGenerators.Common/Directory.Build.props +++ b/GFramework.SourceGenerators.Common/Directory.Build.props @@ -1,12 +1,16 @@ - + - net8.0;net9.0;net10.0 + netstandard2.0 true true + preview - all diff --git a/GFramework.SourceGenerators/GFramework.SourceGenerators.csproj b/GFramework.SourceGenerators/GFramework.SourceGenerators.csproj index 888a09e..e43c807 100644 --- a/GFramework.SourceGenerators/GFramework.SourceGenerators.csproj +++ b/GFramework.SourceGenerators/GFramework.SourceGenerators.csproj @@ -2,7 +2,7 @@ GeWuYou.GFramework.SourceGenerators - net8.0;net9.0;net10.0 + netstandard2.0 true