GeWuYou 32a1734659 feat(logging): 添加日志系统并集成到框架核心组件
- 实现了完整的日志系统,包括ILog接口和ConsoleLogger实现
- 添加了LogConfig配置类和LoggerFactory工厂类
- 在架构、系统、事件、IOC容器等核心组件中集成了日志记录功能
- 添加了NullLogger和CompositeLogger支持
- 创建了详细的日志使用示例和文档
- 实现了日志级别的分类配置和彩色输出功能
2025-12-23 13:08:52 +08:00

32 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace GFramework.Core.logging;
/// <summary>
/// 空日志记录器实现,用于禁用日志记录功能
/// </summary>
internal sealed class NullLogger : ILog
{
/// <summary>
/// 记录日志消息(空实现,不执行任何操作)
/// </summary>
/// <param name="level">日志级别</param>
/// <param name="message">日志消息</param>
/// <param name="exception">相关异常对象(可选)</param>
/// <param name="context">日志上下文信息(可选)</param>
public void Log(LogLevel level, string message, Exception? exception, object? context) { }
/// <summary>
/// 检查指定日志级别是否启用
/// </summary>
/// <param name="level">要检查的日志级别</param>
/// <returns>始终返回 false表示所有日志级别都被禁用</returns>
public bool IsEnabled(LogLevel level) => false;
// 快捷方法实现(空实现)
public void Info(string msg, object? ctx = null) { }
public void Error(string msg, Exception? ex = null, object? ctx = null) { }
public void Debug(string msg, object? ctx = null) { }
public void Trace(string msg, object? ctx = null) { }
public void Warn(string msg, object? ctx = null) { }
public void Fatal(string msg, object? ctx = null) { }
}