From 4fbc067414baa22ca6c157a7cca038f387adac67 Mon Sep 17 00:00:00 2001 From: GwWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Thu, 25 Dec 2025 21:54:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(logging):=20=E4=BF=AE=E5=A4=8DGodotLogger?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=99=A8=E4=B8=AD=E7=9A=84=E5=B7=A5=E5=8E=82?= =?UTF-8?q?=E5=AE=9E=E4=BE=8B=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复GodotLoggerGenerator中GodotLoggerFactory的实例化方式, 从静态方法调用改为实例方法调用 - 将默认日志字段名从"_log"更改为"Logger", 以提供更具描述性的命名 --- .../logging/GodotLogAttribute.cs | 2 +- .../logging/GodotLoggerGenerator.cs | 2 +- GFramework.SourceGenerators.Attributes/logging/LogAttribute.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GFramework.Godot.SourceGenerators.Attributes/logging/GodotLogAttribute.cs b/GFramework.Godot.SourceGenerators.Attributes/logging/GodotLogAttribute.cs index 41a6bdd..704cf0c 100644 --- a/GFramework.Godot.SourceGenerators.Attributes/logging/GodotLogAttribute.cs +++ b/GFramework.Godot.SourceGenerators.Attributes/logging/GodotLogAttribute.cs @@ -29,7 +29,7 @@ public sealed class GodotLogAttribute : Attribute public string? Name { get; set; } /// 生成字段名 - public string FieldName { get; set; } = "_log"; + public string FieldName { get; set; } = "Logger"; /// 是否生成 static 字段 public bool IsStatic { get; set; } = true; diff --git a/GFramework.Godot.SourceGenerators/logging/GodotLoggerGenerator.cs b/GFramework.Godot.SourceGenerators/logging/GodotLoggerGenerator.cs index 3abd4e1..35f4c10 100644 --- a/GFramework.Godot.SourceGenerators/logging/GodotLoggerGenerator.cs +++ b/GFramework.Godot.SourceGenerators/logging/GodotLoggerGenerator.cs @@ -161,7 +161,7 @@ public sealed class GodotLoggerGenerator : IIncrementalGenerator sb.AppendLine(" /// Auto-generated logger"); sb.AppendLine( $" {access} {staticKeyword}readonly ILogger {fieldName} = " + - $"new GodotLoggerFactory.GetLogger(\"{name}\");"); + $"new GodotLoggerFactory().GetLogger(\"{name}\");"); sb.AppendLine(" }"); if (ns is not null) diff --git a/GFramework.SourceGenerators.Attributes/logging/LogAttribute.cs b/GFramework.SourceGenerators.Attributes/logging/LogAttribute.cs index 0f2894e..aff9912 100644 --- a/GFramework.SourceGenerators.Attributes/logging/LogAttribute.cs +++ b/GFramework.SourceGenerators.Attributes/logging/LogAttribute.cs @@ -26,7 +26,7 @@ public sealed class LogAttribute : Attribute public string? Name { get; set; } /// 生成字段名 - public string FieldName { get; set; } = "_log"; + public string FieldName { get; set; } = "Logger"; /// 是否生成 static 字段 public bool IsStatic { get; set; } = true;