GeWuYou bc2b73b19a refactor(generator): 重构日志生成器以使用新属性名称和日志接口
- 将LogAttribute中的Category属性重命名为Name
- 更新构造函数参数名称从category到name
- 添加类和方法的XML文档注释
- 将生成的日志字段类型从ILog改为ILogger
- 更新日志创建方式从Log.CreateLogger到ConsoleLoggerFactory.GetLogger
- 移除项目中的空文件夹引用
- 优化代码结构和注释格式
2025-12-25 08:42:03 +08:00

32 lines
989 B
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;
namespace GFramework.Generator.Attributes.generator.logging;
/// <summary>
/// 标注在类上Source Generator 会为该类自动生成一个日志记录器字段。
/// </summary>
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public sealed class LogAttribute : Attribute
{
/// <summary>日志分类名(默认使用类名)</summary>
public string? Name { get; set; }
/// <summary>生成字段名</summary>
public string FieldName { get; set; } = "_log";
/// <summary>是否生成 static 字段</summary>
public bool IsStatic { get; set; } = true;
/// <summary>访问修饰符</summary>
public string AccessModifier { get; set; } = "private";
public LogAttribute() { }
/// <summary>
/// 初始化 LogAttribute 类的新实例
/// </summary>
/// <param name="name">日志分类名,默认使用类名</param>
public LogAttribute(string? name)
{
Name = name;
}
}