mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 在ArchitectureContext构造函数中添加ILoggerFactory参数 - 为IArchitectureContext接口添加LoggerFactory属性 - 在Architecture的Initialize和InitializeAsync方法中传递loggerFactory - 修改AbstractContextUtility初始化逻辑,使用NoopLoggerFactory创建默认logger - 新增ILogAware接口用于支持日志记录功能 - [no tag]
35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using GFramework.Core.logging;
|
|
using GFramework.Core.rule;
|
|
|
|
namespace GFramework.Core.utility;
|
|
|
|
/// <summary>
|
|
/// 抽象上下文工具类,提供上下文相关的通用功能实现
|
|
/// 继承自ContextAwareBase并实现IContextUtility接口
|
|
/// </summary>
|
|
public abstract class AbstractContextUtility : ContextAwareBase, IContextUtility
|
|
{
|
|
protected ILogger _logger = new NoopLoggerFactory().GetLogger(nameof(AbstractContextUtility));
|
|
|
|
/// <summary>
|
|
/// 初始化上下文工具类
|
|
/// </summary>
|
|
void IContextUtility.Init()
|
|
{
|
|
// 获取上下文中的日志记录器
|
|
_logger = Context.Logger;
|
|
_logger.Debug($"Initializing Context Utility: {GetType().Name}");
|
|
|
|
// 执行子类实现的初始化逻辑
|
|
OnInit();
|
|
|
|
// 记录初始化完成信息
|
|
_logger.Info($"Context Utility initialized: {GetType().Name}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 抽象初始化方法,由子类实现具体的初始化逻辑
|
|
/// </summary>
|
|
protected abstract void OnInit();
|
|
}
|