pub mod compact;
#[cfg(feature = "json")]
pub mod json;
pub mod pretty;
use log::Record;
pub trait Format: Send + Sync {
fn format(&self, record: &Record) -> String;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FormatterType {
Pretty,
Compact,
#[cfg(feature = "json")]
Json,
}
pub fn create_formatter(formatter_type: FormatterType, use_color: bool) -> Box<dyn Format> {
match formatter_type {
FormatterType::Pretty => Box::new(pretty::PrettyFormatter::new(use_color)),
FormatterType::Compact => Box::new(compact::CompactFormatter),
#[cfg(feature = "json")]
FormatterType::Json => Box::new(json::JsonFormatter),
}
}