mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 19:03:29 +08:00
- 实现了完整的日志系统,包括ILog接口和ConsoleLogger实现 - 添加了LogConfig配置类和LoggerFactory工厂类 - 在架构、系统、事件、IOC容器等核心组件中集成了日志记录功能 - 添加了NullLogger和CompositeLogger支持 - 创建了详细的日志使用示例和文档 - 实现了日志级别的分类配置和彩色输出功能
32 lines
1.3 KiB
C#
32 lines
1.3 KiB
C#
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) { }
|
||
}
|