using System.Collections.Generic;
using ZB.MOM.WW.MxGateway.Worker.Bootstrap;

namespace ZB.MOM.WW.MxGateway.Worker.Tests.Bootstrap;

/// <summary>
/// In-memory logger that records all log entries for test inspection.
/// </summary>
internal sealed class MemoryWorkerLogger : IWorkerLogger
{
    /// <summary>
    /// All logged entries recorded in memory.
    /// </summary>
    public List<MemoryWorkerLogEntry> Entries { get; } = new();

    /// <inheritdoc />
    public void Information(string eventName, IReadOnlyDictionary<string, object?> fields)
    {
        Entries.Add(new MemoryWorkerLogEntry("Information", eventName, WorkerLogRedactor.RedactFields(fields)));
    }

    /// <inheritdoc />
    public void Error(string eventName, IReadOnlyDictionary<string, object?> fields)
    {
        Entries.Add(new MemoryWorkerLogEntry("Error", eventName, WorkerLogRedactor.RedactFields(fields)));
    }
}
