GFramework/GFramework.Godot/Logging/GodotLoggerFactory.cs
gewuyou ff553977e3 chore(license): 补齐 Apache-2.0 文件头治理
- 新增许可证文件头检查与修复脚本

- 补充维护者手动修复 PR 工作流和 CI 校验

- 更新贡献指南中的文件头说明

- 补齐仓库维护源码和配置文件的许可证声明
2026-05-03 19:39:49 +08:00

50 lines
1.4 KiB
C#

// Copyright (c) 2025-2026 GeWuYou
// SPDX-License-Identifier: Apache-2.0
using System;
using GFramework.Core.Abstractions.Logging;
namespace GFramework.Godot.Logging;
/// <summary>
/// Creates Godot platform logger instances.
/// </summary>
public sealed class GodotLoggerFactory : ILoggerFactory
{
private readonly GodotLoggerOptions? _options;
/// <summary>
/// Initializes a factory that preserves the historical fixed-format logger behavior.
/// </summary>
public GodotLoggerFactory()
{
}
/// <summary>
/// Initializes a factory with Godot-specific formatting options.
/// </summary>
/// <param name="options">The logger options.</param>
public GodotLoggerFactory(GodotLoggerOptions options)
{
_options = options ?? throw new ArgumentNullException(nameof(options));
}
/// <summary>
/// Gets a logger with the specified name.
/// </summary>
/// <param name="name">The logger name.</param>
/// <param name="minLevel">The minimum enabled level.</param>
/// <returns>A Godot logger instance.</returns>
public ILogger GetLogger(string name, LogLevel minLevel = LogLevel.Info)
{
ArgumentNullException.ThrowIfNull(name);
if (_options == null)
{
return new GodotLogger(name, minLevel);
}
return new GodotLogger(name, _options.WithMinimumLevelFloor(minLevel));
}
}