namespace DodoSSH.Api.Setup;

/// <summary>
/// Source-generated log messages for startup and health.
/// </summary>
/// <remarks>
/// <c>[LoggerMessage]</c> rather than <c>ILogger</c> extension calls: allocation-free, and the
/// event ids and message templates become a stable, greppable inventory instead of string literals
/// scattered through wiring code.
/// </remarks>
internal static partial class StartupLog
{
    [LoggerMessage(
        EventId = 1001,
        Level = LogLevel.Warning,
        Message = "Oidc:RequireHttpsMetadata is false outside Development. Token signing keys are "
            + "being fetched over plaintext HTTP, so anyone on the network path can serve their "
            + "own keys and mint tokens this server will accept.")]
    internal static partial void InsecureMetadataOutsideDevelopment(ILogger logger);

    [LoggerMessage(
        EventId = 1002,
        Level = LogLevel.Warning,
        Message = "Oidc:AllowEmailLinking is enabled. A token from any configured provider "
            + "carrying a victim's email address will be linked to that victim's existing account. "
            + "Only enable this when every configured provider verifies email ownership.")]
    internal static partial void EmailLinkingEnabled(ILogger logger);

    [LoggerMessage(
        EventId = 1010,
        Level = LogLevel.Critical,
        Message = "Database schema is out of date: {PendingCount} migration(s) pending "
            + "({PendingMigrations}). Readiness will fail until they are applied.")]
    internal static partial void PendingMigrations(
        ILogger logger,
        int pendingCount,
        string pendingMigrations);

    [LoggerMessage(
        EventId = 1011,
        Level = LogLevel.Information,
        Message = "Database schema is up to date.")]
    internal static partial void SchemaUpToDate(ILogger logger);

    [LoggerMessage(
        EventId = 1012,
        Level = LogLevel.Information,
        Message = "Applying {PendingCount} pending migration(s): {PendingMigrations}.")]
    internal static partial void ApplyingMigrations(
        ILogger logger,
        int pendingCount,
        string pendingMigrations);

    [LoggerMessage(
        EventId = 1013,
        Level = LogLevel.Information,
        Message = "Applied {AppliedCount} migration(s). The schema is now up to date.")]
    internal static partial void MigrationsApplied(ILogger logger, int appliedCount);

    [LoggerMessage(
        EventId = 1014,
        Level = LogLevel.Information,
        Message = "Database:AutoMigrate is false. This instance will not touch the schema, and will "
            + "fail readiness for as long as a migration is pending.")]
    internal static partial void AutoMigrateDisabled(ILogger logger);

    [LoggerMessage(
        EventId = 1015,
        Level = LogLevel.Warning,
        Message = "The database does not exist yet, so migrations run without the advisory lock that "
            + "normally serialises replicas. Two instances creating it at once will have one of them "
            + "fail and restart into the ordinary path.")]
    internal static partial void MigratingUnlockedDatabase(ILogger logger);
}
