use std::path::PathBuf;
pub use kevy_persist::Fsync as AppendFsync;
pub use kevy_store::EvictionPolicy;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
#[non_exhaustive]
pub enum LogLevel {
Trace,
Debug,
#[default]
Info,
Warn,
Error,
}
impl LogLevel {
pub fn as_str(&self) -> &'static str {
match self {
Self::Trace => "trace",
Self::Debug => "debug",
Self::Info => "info",
Self::Warn => "warning",
Self::Error => "error",
}
}
pub fn parse(s: &str) -> Option<Self> {
match s.to_ascii_lowercase().as_str() {
"trace" => Some(Self::Trace),
"debug" => Some(Self::Debug),
"info" => Some(Self::Info),
"warn" | "warning" => Some(Self::Warn),
"error" => Some(Self::Error),
_ => None,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
#[non_exhaustive]
pub enum LogOutput {
#[default]
Stderr,
Stdout,
File(PathBuf),
}
impl LogOutput {
pub fn to_config_str(&self) -> std::borrow::Cow<'_, str> {
match self {
Self::Stderr => "stderr".into(),
Self::Stdout => "stdout".into(),
Self::File(p) => p.display().to_string().into(),
}
}
pub fn parse(s: &str) -> Self {
match s {
"stderr" => Self::Stderr,
"stdout" => Self::Stdout,
path => Self::File(PathBuf::from(path)),
}
}
}