mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 为 ILoggerFactory 接口添加 minLevel 参数支持 - 实现 ConsoleLoggerFactoryProvider 和 GodotLoggerFactoryProvider - 创建 LoggerFactoryResolver 用于管理日志工厂提供程序 - 为 NoopLoggerFactory 添加日志级别参数 - 在 LogAttribute 中添加 MinLevel 属性 - 更新项目引用以支持日志级别配置功能
44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
#nullable enable
|
||
using System;
|
||
using GFramework.Core.Abstractions.logging;
|
||
|
||
namespace GFramework.SourceGenerators.Abstractions.logging;
|
||
|
||
/// <summary>
|
||
/// 标注在类上,Source Generator 会为该类自动生成一个日志记录器字段。
|
||
/// </summary>
|
||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||
public sealed class LogAttribute : Attribute
|
||
{
|
||
/// <summary>
|
||
/// 初始化 LogAttribute 类的新实例
|
||
/// </summary>
|
||
public LogAttribute()
|
||
{
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化 GodotLogAttribute 类的新实例
|
||
/// </summary>
|
||
/// <param name="name">日志分类名,默认使用类名</param>
|
||
public LogAttribute(string? name)
|
||
{
|
||
Name = name;
|
||
}
|
||
|
||
|
||
/// <summary>日志分类名(默认使用类名)</summary>
|
||
public string? Name { get; set; }
|
||
|
||
/// <summary>生成字段名</summary>
|
||
public string FieldName { get; set; } = "Logger";
|
||
|
||
/// <summary>是否生成 static 字段</summary>
|
||
public bool IsStatic { get; set; } = true;
|
||
|
||
/// <summary>访问修饰符</summary>
|
||
public string AccessModifier { get; set; } = "private";
|
||
|
||
/// <summary>最小日志级别</summary>
|
||
public LogLevel MinLevel { get; set; } = LogLevel.Info;
|
||
} |