using MediatR; using Microsoft.Extensions.Logging; using ZeroFramework.EventBus.Extensions; namespace ZeroFramework.DeviceCenter.Application.Behaviors { public class LoggingBehavior(ILogger> logger) : IPipelineBehavior where TRequest : IRequest { private readonly ILogger> _logger = logger; public async Task Handle(TRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) { _logger.LogInformation("Handling command {CommandName} ({@Command})", request.GetGenericTypeName(), request); var response = await next(); _logger.LogInformation("Command {CommandName} handled - response: {@Response}", request.GetGenericTypeName(), response); return response; } } }