feat: 异常日志、消息日志支持独立日志库

This commit is contained in:
许俊杰 2025-03-09 09:49:42 +08:00
parent 5e0d8e770e
commit cef9036ecc

View File

@ -26,7 +26,9 @@ public class AppEventSubscriber : IEventSubscriber, ISingleton, IDisposable
[EventSubscribe(CommonConst.AddExLog)]
public async Task CreateExLog(EventHandlerExecutingContext context)
{
var db = _serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>();
var db = SqlSugarSetup.ITenant.IsAnyConnection(SqlSugarConst.LogConfigId)
? SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.LogConfigId)
: SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId);
await db.CopyNew().Insertable(context.GetPayload<SysLogEx>()).ExecuteCommandAsync();
}
@ -38,7 +40,9 @@ public class AppEventSubscriber : IEventSubscriber, ISingleton, IDisposable
[EventSubscribe(CommonConst.AddMsgLog)]
public async Task CreateMsgLog(EventHandlerExecutingContext context)
{
var db = _serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>();
var db = SqlSugarSetup.ITenant.IsAnyConnection(SqlSugarConst.LogConfigId)
? SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.LogConfigId)
: SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId);
await db.CopyNew().Insertable(context.GetPayload<SysLogMsg>()).ExecuteCommandAsync();
}