razeri-plugin-contract 0.8.0

The dialect contract Razeri plugins are written against — rendering traits, data types, platform identity
Documentation
// Copyright (C) 2026 Gabriel Shea
// Licensed under either of the Apache License, Version 2.0 or the MIT
// license, at your option.

//! **How loud a message a procedure body writes is.**
//!
//! A generated procedure says things while it runs — that it started, how many
//! rows it saw, that something was off but not fatal. The message is SQL the
//! dialect is handed; the severity is not, because every engine names its
//! levels differently and some have only one. This is the vocabulary that
//! travels with the message.

/// The severity of a message a procedure body writes.
///
/// It is `#[non_exhaustive]`: a dialect matching on it states a fallback rather
/// than assuming the list it compiled against is the list that ships. An engine
/// with one logging statement and no levels — Oracle's `DBMS_OUTPUT` is the
/// worked case — ignores this and spells the message.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum ProcedureLogLevel {
    /// Detail wanted while diagnosing and not otherwise.
    Debug,
    /// The ordinary progress of a run, and the default.
    #[default]
    Info,
    /// Something worth a reader's attention that did not stop the run.
    Warning,
    /// Something that went wrong. It is still a message and not a raise: a
    /// procedure that must stop uses
    /// [`SqlRenderer::render_procedure_raise`](crate::SqlRenderer::render_procedure_raise).
    Error,
}

impl ProcedureLogLevel {
    /// The level's own word, lower case — `"debug"`, `"info"`, `"warning"`,
    /// `"error"`.
    ///
    /// An engine that takes a severity in its logging call reads it from here
    /// and spells it the way that call wants:
    /// `SYSTEM$LOG('INFO', 'loaded')` on Snowflake Scripting is
    /// `level.as_str().to_uppercase()`.
    #[must_use]
    pub fn as_str(self) -> &'static str {
        match self {
            ProcedureLogLevel::Debug => "debug",
            ProcedureLogLevel::Info => "info",
            ProcedureLogLevel::Warning => "warning",
            ProcedureLogLevel::Error => "error",
        }
    }
}