using Microsoft.Extensions.Logging;

namespace ZB.MOM.WW.MxGateway.Server.Diagnostics;

public static class GatewayLoggerExtensions
{
    /// <summary>Begins a gateway log scope with the specified scope properties.</summary>
    /// <param name="logger">Logger used for diagnostic output.</param>
    /// <param name="scope">Scope properties to apply.</param>
    /// <returns>A disposable that ends the scope when disposed.</returns>
    public static IDisposable? BeginGatewayScope(
        this ILogger logger,
        GatewayLogScope scope)
    {
        ArgumentNullException.ThrowIfNull(logger);
        ArgumentNullException.ThrowIfNull(scope);

        return logger.BeginScope(scope.ToDictionary());
    }
}
