mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-23 03:04:29 +08:00
- 将所有小写的命名空间导入更正为首字母大写格式 - 统一 GFramework 框架的命名空间引用规范 - 修复 core、ecs、godot 等模块的命名空间导入错误 - 标准化文档示例代码中的 using 语句格式 - 确保所有文档中的命名空间引用保持一致性 - 更新 global using 语句以匹配正确的命名空间格式
37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
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;
|
|
}
|
|
} |