< Summary

Information
Class: Elsa.Diagnostics.StructuredLogs.ShellFeatures.StructuredLogsFeature
Assembly: Elsa.Diagnostics.StructuredLogs
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Diagnostics.StructuredLogs/ShellFeatures/StructuredLogsFeature.cs
Line coverage
90%
Covered lines: 18
Uncovered lines: 2
Coverable lines: 20
Total lines: 53
Line coverage: 90%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
get_RecentLogCapacity()100%11100%
get_SubscriberChannelCapacity()100%11100%
get_MaxRecentLogQuerySize()100%11100%
get_SourceHeartbeatTimeout()100%11100%
get_IncludeStructuredLogsInternalLogs()100%11100%
get_SensitiveNames()100%11100%
get_SensitiveTextPatterns()100%11100%
ConfigureServices(...)100%11100%
MapEndpoints(...)100%210%
ConfigureOptions(...)100%44100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Diagnostics.StructuredLogs/ShellFeatures/StructuredLogsFeature.cs

#LineLine coverage
 1using CShells.AspNetCore.Features;
 2using CShells.FastEndpoints.Features;
 3using CShells.Features;
 4using Elsa.Diagnostics.StructuredLogs.Extensions;
 5using Elsa.Diagnostics.StructuredLogs.Options;
 6using JetBrains.Annotations;
 7using Microsoft.AspNetCore.Routing;
 8using Microsoft.Extensions.DependencyInjection;
 9using Microsoft.Extensions.Hosting;
 10
 11namespace Elsa.Diagnostics.StructuredLogs.ShellFeatures;
 12
 13/// <summary>
 14/// Provides live structured log streaming over REST and SignalR.
 15/// </summary>
 16[ShellFeature(
 17    DisplayName = "Structured Logs",
 18    Description = "Provides live structured log streaming over REST and SignalR",
 19    DependsOn = ["ElsaFastEndpoints"])]
 20[UsedImplicitly]
 21public class StructuredLogsFeature : IFastEndpointsShellFeature, IWebShellFeature
 22{
 123    private static readonly StructuredLogsOptions DefaultOptions = new();
 24
 425    public int RecentLogCapacity { get; set; } = DefaultOptions.RecentLogCapacity;
 426    public int SubscriberChannelCapacity { get; set; } = DefaultOptions.SubscriberChannelCapacity;
 427    public int MaxRecentLogQuerySize { get; set; } = DefaultOptions.MaxRecentLogQuerySize;
 428    public TimeSpan SourceHeartbeatTimeout { get; set; } = DefaultOptions.SourceHeartbeatTimeout;
 429    public bool IncludeStructuredLogsInternalLogs { get; set; } = DefaultOptions.IncludeStructuredLogsInternalLogs;
 430    public ICollection<string> SensitiveNames { get; set; } = [..DefaultOptions.SensitiveNames];
 431    public ICollection<string> SensitiveTextPatterns { get; set; } = [..DefaultOptions.SensitiveTextPatterns];
 32
 33    public void ConfigureServices(IServiceCollection services)
 34    {
 135        services.AddStructuredLogsServices(ConfigureOptions);
 136    }
 37
 38    public void MapEndpoints(IEndpointRouteBuilder endpoints, IHostEnvironment? environment)
 39    {
 040        endpoints.MapStructuredLogsHub();
 041    }
 42
 43    private void ConfigureOptions(StructuredLogsOptions options)
 44    {
 145        options.RecentLogCapacity = RecentLogCapacity;
 146        options.SubscriberChannelCapacity = SubscriberChannelCapacity;
 147        options.MaxRecentLogQuerySize = MaxRecentLogQuerySize;
 148        options.SourceHeartbeatTimeout = SourceHeartbeatTimeout;
 149        options.IncludeStructuredLogsInternalLogs = IncludeStructuredLogsInternalLogs;
 150        options.SensitiveNames = [..SensitiveNames];
 151        options.SensitiveTextPatterns = [..SensitiveTextPatterns];
 152    }
 53}