Error logging now generates a panic.
This means that the error macro must be called last in the example.
This commit is contained in:
@ -1,3 +1,15 @@
|
||||
#[doc(hidden)]
|
||||
#[macro_export]
|
||||
macro_rules! generate_panic
|
||||
{
|
||||
($($arg: tt)+) =>
|
||||
({
|
||||
use std::fmt;
|
||||
|
||||
panic!(fmt::format(format_args!($($arg)+)));
|
||||
})
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[macro_export]
|
||||
macro_rules! log
|
||||
@ -44,50 +56,44 @@ macro_rules! log
|
||||
macro_rules! error
|
||||
{
|
||||
($($arg: tt)*) =>
|
||||
{
|
||||
{
|
||||
use scribe::LogLevel;
|
||||
({
|
||||
use scribe::LogLevel;
|
||||
|
||||
log!(LogLevel::ERROR, $($arg)*);
|
||||
}
|
||||
}
|
||||
|
||||
log!(LogLevel::ERROR, $($arg)*);
|
||||
generate_panic!($($arg)*);
|
||||
})
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! warn
|
||||
{
|
||||
($($arg: tt)*) =>
|
||||
{
|
||||
{
|
||||
use scribe::LogLevel;
|
||||
({
|
||||
use scribe::LogLevel;
|
||||
|
||||
log!(LogLevel::WARN, $($arg)*);
|
||||
}
|
||||
}
|
||||
log!(LogLevel::WARN, $($arg)*);
|
||||
})
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! info
|
||||
{
|
||||
($($arg: tt)*) =>
|
||||
{
|
||||
{
|
||||
use scribe::LogLevel;
|
||||
({
|
||||
use scribe::LogLevel;
|
||||
|
||||
log!(LogLevel::INFO, $($arg)*);
|
||||
}
|
||||
}
|
||||
log!(LogLevel::INFO, $($arg)*);
|
||||
})
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debug
|
||||
{
|
||||
($($arg: tt)*) =>
|
||||
{
|
||||
{
|
||||
use scribe::LogLevel;
|
||||
({
|
||||
use scribe::LogLevel;
|
||||
|
||||
log!(LogLevel::DEBUG, $($arg)*);
|
||||
}
|
||||
}
|
||||
log!(LogLevel::DEBUG, $($arg)*);
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user