feat:uow & log

This commit is contained in:
xiaolipro 2026-01-15 15:30:57 +08:00
parent f0d96c0cb3
commit b6e3bb6678
2 changed files with 8 additions and 2 deletions

View File

@ -6,6 +6,9 @@
"Microsoft.AspNetCore": "Debug" "Microsoft.AspNetCore": "Debug"
} }
}, },
"Properties": {
"ServiceName": "interface-api"
},
"Enrich": [ "Enrich": [
"FromLogContext", "FromLogContext",
"WithMachineName", "WithMachineName",
@ -16,7 +19,8 @@
{ {
"Name": "Console", "Name": "Console",
"Args": { "Args": {
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {SourceContext} - {Message:lj}{NewLine}{Exception}" "outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {SourceContext} - {Message:lj}{NewLine}{Exception}",
"formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
} }
} }
] ]

View File

@ -1,5 +1,6 @@
using System.Text; using System.Text;
using Fake.DependencyInjection; using Fake.DependencyInjection;
using Fake.UnitOfWork;
using InterfaceForward.Application.Contracts.ForwardCore; using InterfaceForward.Application.Contracts.ForwardCore;
using InterfaceForward.Application.Services; using InterfaceForward.Application.Services;
using InterfaceForward.Domain.Shared; using InterfaceForward.Domain.Shared;
@ -24,7 +25,8 @@ public class BatchForwardEventHandler(
return options.Queue.StartsWith(BatchForwardEventSubscribe); return options.Queue.StartsWith(BatchForwardEventSubscribe);
} }
public async Task Handle(BasicDeliverEventArgs args) [UnitOfWork]
public virtual async Task Handle(BasicDeliverEventArgs args)
{ {
var msg = Encoding.UTF8.GetString(args.Body.ToArray()); var msg = Encoding.UTF8.GetString(args.Body.ToArray());