#[macro_export]
macro_rules! log {
($($arg:tt)*) => {
$crate::output::format_stdout(format!($($arg)*), "\n")
}
}
#[macro_export]
macro_rules! info {
($($arg:tt)*) => {
$crate::output::format_stdout(format!("<cyan><info></> {}", format!($($arg)*)), "\n")
}
}
#[macro_export]
macro_rules! error {
($($arg:tt)*) => {
$crate::output::format_stderr(format!("<red><cross></> {}", format!($($arg)*)), "\n")
}
}
#[macro_export]
macro_rules! warn {
($($arg:tt)*) => {
$crate::output::format_stdout(format!("<yellow><warn></> {}", format!($($arg)*)), "\n")
}
}
#[macro_export]
macro_rules! success {
($($arg:tt)*) => {
$crate::output::format_stdout(format!("<green><tick></> {}", format!($($arg)*)), "\n")
}
}
#[cfg(test)]
mod tests {
#[test]
fn macros() {
log!("This <cyan>is <bright green>a log<//>!");
info!(
"<red>HAHAHAHAHA<///> <black><on green>{}</>",
"the crate supports macros with colors!"
);
error!("This is going to <bright red>stderr</> {}", "WOOOO");
warn!("This is a {} <yellow>BEWARE</>!", "warning");
success!("{} went well, congrats!", "<bright green>Everything</>");
match "a" {
"a" => log!(
"It works inside a match as well!!! {}",
"<bright blue>finally</>"
),
_ => unreachable!(),
}
}
}