< Summary

Information
Class: Elsa.Mediator.Middleware.Command.Components.CommandLoggingMiddleware
Assembly: Elsa.Mediator
File(s): /home/runner/work/elsa-core/elsa-core/src/common/Elsa.Mediator/Middleware/Command/Components/CommandLoggingMiddleware.cs
Line coverage
87%
Covered lines: 7
Uncovered lines: 1
Coverable lines: 8
Total lines: 27
Line coverage: 87.5%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
InvokeAsync()66.66%6685.71%

File(s)

/home/runner/work/elsa-core/elsa-core/src/common/Elsa.Mediator/Middleware/Command/Components/CommandLoggingMiddleware.cs

#LineLine coverage
 1using Elsa.Mediator.Middleware.Command.Contracts;
 2using Elsa.Mediator.Models;
 3using JetBrains.Annotations;
 4using Microsoft.Extensions.Logging;
 5
 6namespace Elsa.Mediator.Middleware.Command.Components;
 7
 8/// <summary>
 9/// A command middleware that logs the command being invoked.
 10/// </summary>
 11[UsedImplicitly]
 112public class CommandLoggingMiddleware(CommandMiddlewareDelegate next, ILogger<CommandLoggingMiddleware> logger) : IComma
 13{
 14    /// <inheritdoc />
 15    public async ValueTask InvokeAsync(CommandContext context)
 16    {
 5517        var commandType = context.Command.GetType();
 5518        logger.LogInformation("Invoking {CommandName}", commandType.Name);
 19
 5520        await next(context);
 21
 5522        if (context.Result is null or Unit)
 5523            logger.LogInformation("{CommandName} completed with no result", commandType.Name);
 24        else
 025            logger.LogInformation("{CommandName} completed with result {CommandResult}", commandType.Name, context.Resul
 5526    }
 27}