You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
845 B
33 lines
845 B
// This stub file contains items which aren't used yet; feel free to remove this module attribute |
|
// to enable stricter warnings. |
|
#![allow(unused)] |
|
|
|
/// various log levels |
|
#[derive(Clone, PartialEq, Debug)] |
|
pub enum LogLevel { |
|
Debug, |
|
Info, |
|
Warning, |
|
Error, |
|
} |
|
|
|
impl std::fmt::Display for LogLevel { |
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
|
let name = format!("{:?}", self); |
|
write!(f, "{}", name.to_uppercase()) |
|
} |
|
} |
|
|
|
/// primary function for emitting logs |
|
pub fn log(level: LogLevel, message: &str) -> String { |
|
format!("[{}]: {}", level, message) |
|
} |
|
pub fn info(message: &str) -> String { |
|
log(LogLevel::Info, message) |
|
} |
|
pub fn warn(message: &str) -> String { |
|
log(LogLevel::Warning, message) |
|
} |
|
pub fn error(message: &str) -> String { |
|
log(LogLevel::Error, message) |
|
}
|
|
|