GwWuYou 435c3398fc feat(logging): 添加日志级别配置和工厂提供程序
- 为 ILoggerFactory 接口添加 minLevel 参数支持
- 实现 ConsoleLoggerFactoryProvider 和 GodotLoggerFactoryProvider
- 创建 LoggerFactoryResolver 用于管理日志工厂提供程序
- 为 NoopLoggerFactory 添加日志级别参数
- 在 LogAttribute 中添加 MinLevel 属性
- 更新项目引用以支持日志级别配置功能
2026-01-01 20:37:12 +08:00

44 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}