fix(logging): 修复GodotLogger生成器中的工厂实例化问题

- 修复GodotLoggerGenerator中GodotLoggerFactory的实例化方式,
  从静态方法调用改为实例方法调用
- 将默认日志字段名从"_log"更改为"Logger",
  以提供更具描述性的命名
This commit is contained in:
GwWuYou 2025-12-25 21:54:32 +08:00
parent b5c1371b86
commit 4fbc067414
3 changed files with 3 additions and 3 deletions

View File

@ -29,7 +29,7 @@ public sealed class GodotLogAttribute : Attribute
public string? Name { get; set; }
/// <summary>生成字段名</summary>
public string FieldName { get; set; } = "_log";
public string FieldName { get; set; } = "Logger";
/// <summary>是否生成 static 字段</summary>
public bool IsStatic { get; set; } = true;

View File

@ -161,7 +161,7 @@ public sealed class GodotLoggerGenerator : IIncrementalGenerator
sb.AppendLine(" /// <summary>Auto-generated logger</summary>");
sb.AppendLine(
$" {access} {staticKeyword}readonly ILogger {fieldName} = " +
$"new GodotLoggerFactory.GetLogger(\"{name}\");");
$"new GodotLoggerFactory().GetLogger(\"{name}\");");
sb.AppendLine(" }");
if (ns is not null)

View File

@ -26,7 +26,7 @@ public sealed class LogAttribute : Attribute
public string? Name { get; set; }
/// <summary>生成字段名</summary>
public string FieldName { get; set; } = "_log";
public string FieldName { get; set; } = "Logger";
/// <summary>是否生成 static 字段</summary>
public bool IsStatic { get; set; } = true;