mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 19:03:29 +08:00
- 将LogAttribute中的Category属性重命名为Name - 更新构造函数参数名称从category到name - 添加类和方法的XML文档注释 - 将生成的日志字段类型从ILog改为ILogger - 更新日志创建方式从Log.CreateLogger到ConsoleLoggerFactory.GetLogger - 移除项目中的空文件夹引用 - 优化代码结构和注释格式
32 lines
989 B
C#
32 lines
989 B
C#
#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;
|
||
}
|
||
} |