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

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

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

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

40 lines
1.1 KiB
C#

// Copyright (c) 2025-2026 GeWuYou
// SPDX-License-Identifier: Apache-2.0
namespace GFramework.Core.Abstractions.Logging;
/// <summary>
/// 日志条目,包含完整的日志信息
/// </summary>
public sealed record LogEntry(
DateTime Timestamp,
LogLevel Level,
string LoggerName,
string Message,
Exception? Exception,
IReadOnlyDictionary<string, object?>? Properties)
{
/// <summary>
/// 获取合并了上下文属性的所有属性
/// </summary>
/// <returns>包含日志属性和上下文属性的字典</returns>
public IReadOnlyDictionary<string, object?> GetAllProperties()
{
var contextProps = LogContext.Current;
if (Properties == null || Properties.Count == 0)
return contextProps;
if (contextProps.Count == 0)
return Properties;
// 合并属性,日志属性优先
var merged = new Dictionary<string, object?>(contextProps, StringComparer.Ordinal);
foreach (var prop in Properties)
{
merged[prop.Key] = prop.Value;
}
return merged;
}
}