namespace DodoSSH.Api.Features.Events;

/// <summary>Source-generated log messages for the event socket.</summary>
/// <remarks>
/// Ids and counts only, as everywhere else. A notice carries no ciphertext to leak, but which vault
/// changed and when is still the metadata ADR 0001 asks be kept to what is diagnostically useful.
/// </remarks>
internal static partial class EventsLog
{
    [LoggerMessage(
        EventId = 2201,
        Level = LogLevel.Debug,
        Message = "Event socket opened for user {UserId} following {VaultCount} vault(s); "
            + "{ConnectionCount} open on this node.")]
    internal static partial void ConnectionOpened(
        ILogger logger,
        Guid userId,
        int vaultCount,
        int connectionCount);

    [LoggerMessage(
        EventId = 2202,
        Level = LogLevel.Debug,
        Message = "Event socket closed for user {UserId}; {ConnectionCount} open on this node.")]
    internal static partial void ConnectionClosed(ILogger logger, Guid userId, int connectionCount);

    /// <remarks>
    /// Information rather than Debug: a refused socket is a client that will poll for the rest of its
    /// session, and an operator seeing these has a cap to raise.
    /// </remarks>
    [LoggerMessage(
        EventId = 2203,
        Level = LogLevel.Information,
        Message = "Refused an event socket for user {UserId}: {Limit} is already reached.")]
    internal static partial void ConnectionRefused(ILogger logger, Guid userId, string limit);

    [LoggerMessage(
        EventId = 2204,
        Level = LogLevel.Debug,
        Message = "Announced vault {VaultId} at sequence {Sequence} to {ConnectionCount} socket(s).")]
    internal static partial void VaultChangePublished(
        ILogger logger,
        Guid vaultId,
        long sequence,
        int connectionCount);

    [LoggerMessage(
        EventId = 2205,
        Level = LogLevel.Debug,
        Message = "Announced a vault access change to {ConnectionCount} socket(s) of user {UserId}.")]
    internal static partial void AccessChangePublished(ILogger logger, Guid userId, int connectionCount);

    /// <remarks>
    /// Warning, and it is worth being loud: the socket is still open and still delivering, but it is
    /// delivering about a vault set that may be stale. Everything else here is routine.
    /// </remarks>
    [LoggerMessage(
        EventId = 2206,
        Level = LogLevel.Warning,
        Message = "Could not re-resolve which vaults user {UserId}'s event socket may follow.")]
    internal static partial void AccessRefreshFailed(ILogger logger, Guid userId, Exception exception);

    [LoggerMessage(
        EventId = 2207,
        Level = LogLevel.Debug,
        Message = "Closing user {UserId}'s event socket: {Reason}.")]
    internal static partial void ClosingConnection(ILogger logger, Guid userId, string reason);
}
