Error logging now generates a panic.
This means that the error macro must be called last in the example.
This commit is contained in:
parent
d1e6e8f4fe
commit
d6a6f5107c
@ -5,8 +5,8 @@ extern crate scribe;
|
||||
|
||||
pub fn main()
|
||||
{
|
||||
error!("There was an error!");
|
||||
warn!("Danger Will Robinson, danger!");
|
||||
info!("Jason is awesome.");
|
||||
debug!("This seemed to work alright.");
|
||||
info!("Jason is awesome.");
|
||||
warn!("Danger Will Robinson, danger!");
|
||||
error!("There was an error!");
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
||||
log!(LogLevel::ERROR, $($arg)*);
|
||||
}
|
||||
}
|
||||
generate_panic!($($arg)*);
|
||||
})
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! warn
|
||||
{
|
||||
($($arg: tt)*) =>
|
||||
{
|
||||
{
|
||||
({
|
||||
use scribe::LogLevel;
|
||||
|
||||
log!(LogLevel::WARN, $($arg)*);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! info
|
||||
{
|
||||
($($arg: tt)*) =>
|
||||
{
|
||||
{
|
||||
({
|
||||
use scribe::LogLevel;
|
||||
|
||||
log!(LogLevel::INFO, $($arg)*);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debug
|
||||
{
|
||||
($($arg: tt)*) =>
|
||||
{
|
||||
{
|
||||
({
|
||||
use scribe::LogLevel;
|
||||
|
||||
log!(LogLevel::DEBUG, $($arg)*);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user