//! Minimal stderr logging utilities.

/// Logging verbosity level.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Verbosity {
    /// Suppress warnings and informational messages.
    Quiet,
    /// Emit warnings but suppress informational messages.
    Normal,
    /// Emit warnings and informational messages.
    Verbose,
}

/// Lightweight logger used by renderers and generators.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct Logger {
    verbosity: Verbosity,
}

impl Logger {
    /// Creates a logger with the given verbosity.
    pub fn new(verbosity: Verbosity) -> Self {
        Self { verbosity }
    }

    /// Emits a warning unless verbosity is [`Verbosity::Quiet`].
    pub fn warn(&self, message: impl AsRef<str>) {
        if self.verbosity != Verbosity::Quiet {
            eprintln!("Warning: {}", message.as_ref());
        }
    }

    /// Emits an informational message only when verbosity is [`Verbosity::Verbose`].
    pub fn info(&self, message: impl AsRef<str>) {
        if self.verbosity == Verbosity::Verbose {
            eprintln!("Info: {}", message.as_ref());
        }
    }
}

impl Default for Logger {
    fn default() -> Self {
        Self {
            verbosity: Verbosity::Quiet,
        }
    }
}
