namespace Mbproxy.Proxy.Cache;

/// <summary>
/// Source-generated <see cref="LoggerMessage"/> definitions for the response cache.
/// Event names are stable — do not rename without updating <c>docs/Reference/LogEvents.md</c>'s
/// Logging event-name table.
///
/// <para>Levels are conservative — a busy PLC under steady cache pressure would emit one
/// Hit / Miss per FC03/FC04 request. The counters surface the same data at far lower cost
/// for monitoring; Debug-level events are present for incident-time diagnosis only.</para>
/// </summary>
internal static partial class CacheLogEvents
{
    [LoggerMessage(
        EventId   = 140,
        EventName = "mbproxy.cache.hit",
        Level     = LogLevel.Debug,
        Message   = "Cache hit: Plc={Plc} Unit={UnitId} Fc={Fc} Start={Start} Qty={Qty}")]
    public static partial void Hit(
        ILogger logger,
        string plc,
        byte unitId,
        byte fc,
        ushort start,
        ushort qty);

    [LoggerMessage(
        EventId   = 141,
        EventName = "mbproxy.cache.miss",
        Level     = LogLevel.Debug,
        Message   = "Cache 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);

    [LoggerMessage(
        EventId   = 142,
        EventName = "mbproxy.cache.store",
        Level     = LogLevel.Debug,
        Message   = "Cache store: Plc={Plc} Unit={UnitId} Fc={Fc} Start={Start} Qty={Qty} TtlMs={TtlMs}")]
    public static partial void Store(
        ILogger logger,
        string plc,
        byte unitId,
        byte fc,
        ushort start,
        ushort qty,
        int ttlMs);

    [LoggerMessage(
        EventId   = 143,
        EventName = "mbproxy.cache.invalidated",
        Level     = LogLevel.Debug,
        Message   = "Cache invalidated: Plc={Plc} Unit={UnitId} WriteStart={WriteStart} WriteQty={WriteQty} Count={Count}")]
    public static partial void Invalidated(
        ILogger logger,
        string plc,
        byte unitId,
        ushort writeStart,
        ushort writeQty,
        int count);

    [LoggerMessage(
        EventId   = 144,
        EventName = "mbproxy.cache.flushed",
        Level     = LogLevel.Information,
        Message   = "Cache flushed: Plc={Plc} Reason={Reason} Count={Count}")]
    public static partial void Flushed(
        ILogger logger,
        string plc,
        string reason,
        int count);
}
