use glyphs::Color;
#[derive(Debug, Clone)]
pub struct LogStyle {
pub timestamp: bool,
pub timestamp_format: String,
pub show_level: bool,
pub short_level: bool,
pub show_icons: bool,
pub timestamp_color: Color,
pub key_color: Color,
pub value_color: Color,
pub message_color: Color,
pub separator: String,
pub kv_separator: String,
}
impl Default for LogStyle {
fn default() -> Self {
Self {
timestamp: false,
timestamp_format: "%H:%M:%S".to_string(),
show_level: true,
short_level: false,
show_icons: false,
timestamp_color: Color::from_hex("#71717A"),
key_color: Color::from_hex("#A1A1AA"),
value_color: Color::from_hex("#E4E4E7"),
message_color: Color::from_hex("#FAFAFA"),
separator: " ".to_string(),
kv_separator: "=".to_string(),
}
}
}
impl LogStyle {
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn with_timestamp(mut self) -> Self {
self.timestamp = true;
self
}
#[must_use]
pub fn timestamp_format(mut self, format: impl Into<String>) -> Self {
self.timestamp_format = format.into();
self
}
#[must_use]
pub fn short_level(mut self) -> Self {
self.short_level = true;
self
}
#[must_use]
pub fn with_icons(mut self) -> Self {
self.show_icons = true;
self
}
#[must_use]
pub fn hide_level(mut self) -> Self {
self.show_level = false;
self
}
#[must_use]
pub fn key_color(mut self, color: Color) -> Self {
self.key_color = color;
self
}
pub fn minimal() -> Self {
Self {
show_level: false,
..Default::default()
}
}
pub fn full() -> Self {
Self {
timestamp: true,
show_icons: true,
..Default::default()
}
}
pub fn json_like() -> Self {
Self {
kv_separator: ": ".to_string(),
separator: ", ".to_string(),
..Default::default()
}
}
}