use std::cmp::Ordering;

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LogLevel {
    /// Verbose record of decisions and operations.
    Info,
    /// Report recoverable issues.
    Warn,
    /// Report unrecoverable errors and quit.
    Error,
}

impl PartialOrd for LogLevel {
    fn partial_cmp(&self, other: &LogLevel) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl Ord for LogLevel {
    fn cmp(&self, other: &LogLevel) -> Ordering {
        use LogLevel::*;
        match (self, other) {
            (Info , Info ) => Ordering::Equal,
            (Info , Warn ) => Ordering::Less,
            (Info , Error) => Ordering::Less,

            (Warn , Info ) => Ordering::Greater,
            (Warn , Warn ) => Ordering::Equal,
            (Warn , Error) => Ordering::Less,

            (Error , Info ) => Ordering::Greater,
            (Error , Warn ) => Ordering::Greater,
            (Error , Error) => Ordering::Equal,
        }
    }
}