namespace Mbproxy.Proxy.Multiplexing;

/// <summary>
/// Source-generated <see cref="LoggerMessage"/> definitions for the read-coalescing
/// feature. Event names are stable — do not rename without updating docs/Reference/LogEvents.md's
/// "Logging" event-name table.
///
/// <para>Levels are intentionally conservative — coalescing fires on every overlapping
/// read in a busy fleet (HMIs/historians polling the same screen tags), so the
/// steady-state log volume would be deafening at Information. The counters surface the
/// same data at far lower cost.</para>
/// </summary>
internal static partial class CoalescingLogEvents
{
    /// <summary>
    /// Emitted at Debug when an FC03/FC04 request attaches to an already-in-flight peer.
    /// </summary>
    [LoggerMessage(
        EventId   = 120,
        EventName = "mbproxy.coalesce.hit",
        Level     = LogLevel.Debug,
        Message   = "Coalesce hit: Plc={Plc} Unit={UnitId} Fc={Fc} Start={Start} Qty={Qty} PartyCount={PartyCount}")]
    public static partial void Hit(
        ILogger logger,
        string  plc,
        byte    unitId,
        byte    fc,
        ushort  start,
        ushort  qty,
        int     partyCount);

    /// <summary>
    /// Emitted at Debug when an FC03/FC04 request opens a fresh in-flight entry (no
    /// matching peer was found, or the matching peer had reached its <c>MaxParties</c> cap).
    /// </summary>
    [LoggerMessage(
        EventId   = 121,
        EventName = "mbproxy.coalesce.miss",
        Level     = LogLevel.Debug,
        Message   = "Coalesce miss: Plc={Plc} Unit={UnitId} Fc={Fc} Start={Start} Qty={Qty}")]
    public static partial void Miss(
        ILogger logger,
        string  plc,
        byte    unitId,
        byte    fc,
        ushort  start,
        ushort  qty);

    /// <summary>
    /// Emitted at Debug when fan-out skips a coalesced party because its upstream pipe is
    /// no longer alive. The corresponding counter increments at every occurrence.
    /// </summary>
    [LoggerMessage(
        EventId   = 122,
        EventName = "mbproxy.coalesce.dead_upstream",
        Level     = LogLevel.Debug,
        Message   = "Coalesce dead upstream: Plc={Plc} Unit={UnitId} Fc={Fc} Start={Start} Qty={Qty}")]
    public static partial void DeadUpstream(
        ILogger logger,
        string  plc,
        byte    unitId,
        byte    fc,
        ushort  start,
        ushort  qty);
}
