< Summary

Information
Class: Elsa.Alterations.Core.Models.AlterationLog
Assembly: Elsa.Alterations.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations.Core/Models/AlterationLog.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 9
Coverable lines: 9
Total lines: 46
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
get_LogEntries()100%210%
Add(...)100%210%
AddRange(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations.Core/Models/AlterationLog.cs

#LineLine coverage
 1using Elsa.Common;
 2using Microsoft.Extensions.Logging;
 3
 4namespace Elsa.Alterations.Core.Models;
 5
 6
 7/// <summary>
 8/// Represents a log of alterations.
 9/// </summary>
 10public class AlterationLog
 11{
 12    private readonly ISystemClock _systemClock;
 013    private readonly List<AlterationLogEntry> _logEntries = new();
 14
 15    /// <summary>
 16    /// Initializes a new instance of the <see cref="AlterationLog"/> class.
 17    /// </summary>
 018    public AlterationLog(ISystemClock systemClock)
 19    {
 020        _systemClock = systemClock;
 021    }
 22
 23    /// <summary>
 24    /// Gets the log entries.
 25    /// </summary>
 026    public IReadOnlyCollection<AlterationLogEntry> LogEntries => _logEntries.ToList().AsReadOnly();
 27
 28    /// <summary>
 29    /// Adds a log entry.
 30    /// </summary>
 31    /// <param name="message">The message.</param>
 32    /// <param name="logLevel">The log level.</param>
 33    /// <param name="eventName">The event that generated the log entry.</param>
 34    public void Add(string message, LogLevel logLevel = LogLevel.Information, string? eventName = null)
 35    {
 036        var entry = new AlterationLogEntry(message, logLevel, _systemClock.UtcNow, eventName);
 37
 038        _logEntries.Add(entry);
 039    }
 40
 41    /// <summary>
 42    /// Adds a set of log entries.
 43    /// </summary>
 44    /// <param name="entries"></param>
 045    public void AddRange(IEnumerable<AlterationLogEntry> entries) => _logEntries.AddRange(entries);
 46}