#[macro_export]
macro_rules! span {
(target: $target:expr, parent: $parent:expr, $lvl:expr, $name:expr) => {
$crate::span!(target: $target, parent: $parent, $lvl, $name,)
};
(target: $target:expr, parent: $parent:expr, $lvl:expr, $name:expr, $($fields:tt)*) => {
{
use $crate::__macro_support::Callsite as _;
static CALLSITE: $crate::__macro_support::MacroCallsite = $crate::callsite2! {
name: $name,
kind: $crate::metadata::Kind::SPAN,
target: $target,
level: $lvl,
fields: $($fields)*
};
let mut interest = $crate::subscriber::Interest::never();
if $crate::level_enabled!($lvl)
&& { interest = CALLSITE.interest(); !interest.is_never() }
&& CALLSITE.is_enabled(interest)
{
let meta = CALLSITE.metadata();
$crate::Span::child_of(
$parent,
meta,
&$crate::valueset!(meta.fields(), $($fields)*),
)
} else {
let span = CALLSITE.disabled_span();
$crate::if_log_enabled! {{
span.record_all(&$crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
}};
span
}
}
};
(target: $target:expr, $lvl:expr, $name:expr, $($fields:tt)*) => {
{
use $crate::__macro_support::Callsite as _;
static CALLSITE: $crate::__macro_support::MacroCallsite = $crate::callsite2! {
name: $name,
kind: $crate::metadata::Kind::SPAN,
target: $target,
level: $lvl,
fields: $($fields)*
};
let mut interest = $crate::subscriber::Interest::never();
if $crate::level_enabled!($lvl)
&& { interest = CALLSITE.interest(); !interest.is_never() }
&& CALLSITE.is_enabled(interest)
{
let meta = CALLSITE.metadata();
$crate::Span::new(
meta,
&$crate::valueset!(meta.fields(), $($fields)*),
)
} else {
let span = CALLSITE.disabled_span();
$crate::if_log_enabled! {{
span.record_all(&$crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
}};
span
}
}
};
(target: $target:expr, parent: $parent:expr, $lvl:expr, $name:expr) => {
$crate::span!(target: $target, parent: $parent, $lvl, $name,)
};
(parent: $parent:expr, $lvl:expr, $name:expr, $($fields:tt)*) => {
$crate::span!(
target: module_path!(),
parent: $parent,
$lvl,
$name,
$($fields)*
)
};
(parent: $parent:expr, $lvl:expr, $name:expr) => {
$crate::span!(
target: module_path!(),
parent: $parent,
$lvl,
$name,
)
};
(target: $target:expr, $lvl:expr, $name:expr, $($fields:tt)*) => {
$crate::span!(
target: $target,
$lvl,
$name,
$($fields)*
)
};
(target: $target:expr, $lvl:expr, $name:expr) => {
$crate::span!(target: $target, $lvl, $name,)
};
($lvl:expr, $name:expr, $($fields:tt)*) => {
$crate::span!(
target: module_path!(),
$lvl,
$name,
$($fields)*
)
};
($lvl:expr, $name:expr) => {
$crate::span!(
target: module_path!(),
$lvl,
$name,
)
};
}
#[macro_export]
macro_rules! trace_span {
(target: $target:expr, parent: $parent:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: $target,
parent: $parent,
$crate::Level::TRACE,
$name,
$($field)*
)
};
(target: $target:expr, parent: $parent:expr, $name:expr) => {
$crate::trace_span!(target: $target, parent: $parent, $name,)
};
(parent: $parent:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: module_path!(),
parent: $parent,
$crate::Level::TRACE,
$name,
$($field)*
)
};
(parent: $parent:expr, $name:expr) => {
$crate::trace_span!(parent: $parent, $name,)
};
(target: $target:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: $target,
$crate::Level::TRACE,
$name,
$($field)*
)
};
(target: $target:expr, $name:expr) => {
$crate::trace_span!(target: $target, $name,)
};
($name:expr, $($field:tt)*) => {
$crate::span!(
target: module_path!(),
$crate::Level::TRACE,
$name,
$($field)*
)
};
($name:expr) => { $crate::trace_span!($name,) };
}
#[macro_export]
macro_rules! debug_span {
(target: $target:expr, parent: $parent:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: $target,
parent: $parent,
$crate::Level::DEBUG,
$name,
$($field)*
)
};
(target: $target:expr, parent: $parent:expr, $name:expr) => {
$crate::debug_span!(target: $target, parent: $parent, $name,)
};
(parent: $parent:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: module_path!(),
parent: $parent,
$crate::Level::DEBUG,
$name,
$($field)*
)
};
(parent: $parent:expr, $name:expr) => {
$crate::debug_span!(parent: $parent, $name,)
};
(target: $target:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: $target,
$crate::Level::DEBUG,
$name,
$($field)*
)
};
(target: $target:expr, $name:expr) => {
$crate::debug_span!(target: $target, $name,)
};
($name:expr, $($field:tt)*) => {
$crate::span!(
target: module_path!(),
$crate::Level::DEBUG,
$name,
$($field)*
)
};
($name:expr) => {$crate::debug_span!($name,)};
}
#[macro_export]
macro_rules! info_span {
(target: $target:expr, parent: $parent:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: $target,
parent: $parent,
$crate::Level::INFO,
$name,
$($field)*
)
};
(target: $target:expr, parent: $parent:expr, $name:expr) => {
$crate::info_span!(target: $target, parent: $parent, $name,)
};
(parent: $parent:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: module_path!(),
parent: $parent,
$crate::Level::INFO,
$name,
$($field)*
)
};
(parent: $parent:expr, $name:expr) => {
$crate::info_span!(parent: $parent, $name,)
};
(target: $target:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: $target,
$crate::Level::INFO,
$name,
$($field)*
)
};
(target: $target:expr, $name:expr) => {
$crate::info_span!(target: $target, $name,)
};
($name:expr, $($field:tt)*) => {
$crate::span!(
target: module_path!(),
$crate::Level::INFO,
$name,
$($field)*
)
};
($name:expr) => {$crate::info_span!($name,)};
}
#[macro_export]
macro_rules! warn_span {
(target: $target:expr, parent: $parent:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: $target,
parent: $parent,
$crate::Level::WARN,
$name,
$($field)*
)
};
(target: $target:expr, parent: $parent:expr, $name:expr) => {
$crate::warn_span!(target: $target, parent: $parent, $name,)
};
(parent: $parent:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: module_path!(),
parent: $parent,
$crate::Level::WARN,
$name,
$($field)*
)
};
(parent: $parent:expr, $name:expr) => {
$crate::warn_span!(parent: $parent, $name,)
};
(target: $target:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: $target,
$crate::Level::WARN,
$name,
$($field)*
)
};
(target: $target:expr, $name:expr) => {
$crate::warn_span!(target: $target, $name,)
};
($name:expr, $($field:tt)*) => {
$crate::span!(
target: module_path!(),
$crate::Level::WARN,
$name,
$($field)*
)
};
($name:expr) => {$crate::warn_span!($name,)};
}
#[macro_export]
macro_rules! error_span {
(target: $target:expr, parent: $parent:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: $target,
parent: $parent,
$crate::Level::ERROR,
$name,
$($field)*
)
};
(target: $target:expr, parent: $parent:expr, $name:expr) => {
$crate::error_span!(target: $target, parent: $parent, $name,)
};
(parent: $parent:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: module_path!(),
parent: $parent,
$crate::Level::ERROR,
$name,
$($field)*
)
};
(parent: $parent:expr, $name:expr) => {
$crate::error_span!(parent: $parent, $name,)
};
(target: $target:expr, $name:expr, $($field:tt)*) => {
$crate::span!(
target: $target,
$crate::Level::ERROR,
$name,
$($field)*
)
};
(target: $target:expr, $name:expr) => {
$crate::error_span!(target: $target, $name,)
};
($name:expr, $($field:tt)*) => {
$crate::span!(
target: module_path!(),
$crate::Level::ERROR,
$name,
$($field)*
)
};
($name:expr) => {$crate::error_span!($name,)};
}
#[macro_export]
macro_rules! event {
(target: $target:expr, parent: $parent:expr, $lvl:expr, { $($fields:tt)* } )=> (
$crate::__tracing_log!(
target: $target,
$lvl,
$($fields)*
);
if $crate::level_enabled!($lvl) {
use $crate::__macro_support::*;
static CALLSITE: $crate::__macro_support::MacroCallsite = $crate::callsite2! {
name: concat!(
"event ",
file!(),
":",
line!()
),
kind: $crate::metadata::Kind::EVENT,
target: $target,
level: $lvl,
fields: $($fields)*
};
let interest = CALLSITE.interest();
if !interest.is_never() && CALLSITE.is_enabled(interest) {
let meta = CALLSITE.metadata();
$crate::Event::child_of(
$parent,
meta,
&$crate::valueset!(meta.fields(), $($fields)*)
);
}
}
);
(target: $target:expr, parent: $parent:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) => (
$crate::event!(
target: $target,
parent: $parent,
$lvl,
{ message = format_args!($($arg)+), $($fields)* }
)
);
(target: $target:expr, parent: $parent:expr, $lvl:expr, $($k:ident).+ = $($fields:tt)* ) => (
$crate::event!(target: $target, parent: $parent, $lvl, { $($k).+ = $($fields)* })
);
(target: $target:expr, parent: $parent:expr, $lvl:expr, $($arg:tt)+) => (
$crate::event!(target: $target, parent: $parent, $lvl, { $($arg)+ })
);
(target: $target:expr, $lvl:expr, { $($fields:tt)* } )=> ({
$crate::__tracing_log!(
target: $target,
$lvl,
$($fields)*
);
if $crate::level_enabled!($lvl) {
use $crate::__macro_support::*;
static CALLSITE: $crate::__macro_support::MacroCallsite = $crate::callsite2! {
name: concat!(
"event ",
file!(),
":",
line!()
),
kind: $crate::metadata::Kind::EVENT,
target: $target,
level: $lvl,
fields: $($fields)*
};
let interest = CALLSITE.interest();
if !interest.is_never() && CALLSITE.is_enabled(interest) {
let meta = CALLSITE.metadata();
$crate::Event::dispatch(
meta,
&$crate::valueset!(meta.fields(), $($fields)*)
);
}
}
});
(target: $target:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) => (
$crate::event!(
target: $target,
$lvl,
{ message = format_args!($($arg)+), $($fields)* }
)
);
(target: $target:expr, $lvl:expr, $($k:ident).+ = $($fields:tt)* ) => (
$crate::event!(target: $target, $lvl, { $($k).+ = $($fields)* })
);
(target: $target:expr, $lvl:expr, $($arg:tt)+ ) => (
$crate::event!(target: $target, $lvl, { $($arg)+ })
);
(parent: $parent:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$lvl,
{ message = format_args!($($arg)+), $($fields)* }
)
);
(parent: $parent:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
$lvl,
parent: $parent,
{ message = format_args!($($arg)+), $($fields)* }
)
);
(parent: $parent:expr, $lvl:expr, $($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$lvl,
{ $($k).+ = $($field)*}
)
);
(parent: $parent:expr, $lvl:expr, ?$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$lvl,
{ ?$($k).+ = $($field)*}
)
);
(parent: $parent:expr, $lvl:expr, %$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$lvl,
{ %$($k).+ = $($field)*}
)
);
(parent: $parent:expr, $lvl:expr, $($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$lvl,
{ $($k).+, $($field)*}
)
);
(parent: $parent:expr, $lvl:expr, %$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$lvl,
{ %$($k).+, $($field)*}
)
);
(parent: $parent:expr, $lvl:expr, ?$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$lvl,
{ ?$($k).+, $($field)*}
)
);
(parent: $parent:expr, $lvl:expr, $($arg:tt)+ ) => (
$crate::event!(target: module_path!(), parent: $parent, $lvl, { $($arg)+ })
);
( $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
$lvl,
{ message = format_args!($($arg)+), $($fields)* }
)
);
( $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
$lvl,
{ message = format_args!($($arg)+), $($fields)* }
)
);
($lvl:expr, $($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$lvl,
{ $($k).+ = $($field)*}
)
);
($lvl:expr, $($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$lvl,
{ $($k).+, $($field)*}
)
);
($lvl:expr, ?$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$lvl,
{ ?$($k).+, $($field)*}
)
);
($lvl:expr, %$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$lvl,
{ %$($k).+, $($field)*}
)
);
($lvl:expr, ?$($k:ident).+) => (
$crate::event!($lvl, ?$($k).+,)
);
($lvl:expr, %$($k:ident).+) => (
$crate::event!($lvl, %$($k).+,)
);
($lvl:expr, $($k:ident).+) => (
$crate::event!($lvl, $($k).+,)
);
( $lvl:expr, $($arg:tt)+ ) => (
$crate::event!(target: module_path!(), $lvl, { $($arg)+ })
);
}
#[macro_export]
macro_rules! trace {
(target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::TRACE, { $($field)* }, $($arg)*)
);
(target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::TRACE, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::TRACE, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::TRACE, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::TRACE, {}, $($arg)+)
);
(parent: $parent:expr, { $($field:tt)+ }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::TRACE,
{ $($field)+ },
$($arg)+
)
);
(parent: $parent:expr, $($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::TRACE,
{ $($k).+ = $($field)*}
)
);
(parent: $parent:expr, ?$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::TRACE,
{ ?$($k).+ = $($field)*}
)
);
(parent: $parent:expr, %$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::TRACE,
{ %$($k).+ = $($field)*}
)
);
(parent: $parent:expr, $($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::TRACE,
{ $($k).+, $($field)*}
)
);
(parent: $parent:expr, ?$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::TRACE,
{ ?$($k).+, $($field)*}
)
);
(parent: $parent:expr, %$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::TRACE,
{ %$($k).+, $($field)*}
)
);
(parent: $parent:expr, $($arg:tt)+) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::TRACE,
{},
$($arg)+
)
);
(target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => (
$crate::event!(target: $target, $crate::Level::TRACE, { $($field)* }, $($arg)*)
);
(target: $target:expr, $($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::TRACE, { $($k).+ $($field)+ })
);
(target: $target:expr, ?$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::TRACE, { $($k).+ $($field)+ })
);
(target: $target:expr, %$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::TRACE, { $($k).+ $($field)+ })
);
(target: $target:expr, $($arg:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::TRACE, {}, $($arg)+)
);
({ $($field:tt)+ }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
$crate::Level::TRACE,
{ $($field)+ },
$($arg)+
)
);
($($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::TRACE,
{ $($k).+ = $($field)*}
)
);
($($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::TRACE,
{ $($k).+, $($field)*}
)
);
(?$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::TRACE,
{ ?$($k).+, $($field)*}
)
);
(%$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::TRACE,
{ %$($k).+, $($field)*}
)
);
(?$($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::TRACE,
{ ?$($k).+ }
)
);
(%$($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::TRACE,
{ %$($k).+ }
)
);
($($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::TRACE,
{ $($k).+ }
)
);
($($arg:tt)+) => (
$crate::event!(
target: module_path!(),
$crate::Level::TRACE,
{},
$($arg)+
)
);
}
#[macro_export]
macro_rules! debug {
(target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::DEBUG, { $($field)* }, $($arg)*)
);
(target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::DEBUG, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::DEBUG, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::DEBUG, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::DEBUG, {}, $($arg)+)
);
(parent: $parent:expr, { $($field:tt)+ }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::DEBUG,
{ $($field)+ },
$($arg)+
)
);
(parent: $parent:expr, $($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::DEBUG,
{ $($k).+ = $($field)*}
)
);
(parent: $parent:expr, ?$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::DEBUG,
{ ?$($k).+ = $($field)*}
)
);
(parent: $parent:expr, %$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::DEBUG,
{ %$($k).+ = $($field)*}
)
);
(parent: $parent:expr, $($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::DEBUG,
{ $($k).+, $($field)*}
)
);
(parent: $parent:expr, ?$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::DEBUG,
{ ?$($k).+, $($field)*}
)
);
(parent: $parent:expr, %$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::DEBUG,
{ %$($k).+, $($field)*}
)
);
(parent: $parent:expr, $($arg:tt)+) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::DEBUG,
{},
$($arg)+
)
);
(target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => (
$crate::event!(target: $target, $crate::Level::DEBUG, { $($field)* }, $($arg)*)
);
(target: $target:expr, $($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::DEBUG, { $($k).+ $($field)+ })
);
(target: $target:expr, ?$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::DEBUG, { $($k).+ $($field)+ })
);
(target: $target:expr, %$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::DEBUG, { $($k).+ $($field)+ })
);
(target: $target:expr, $($arg:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::DEBUG, {}, $($arg)+)
);
({ $($field:tt)+ }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
$crate::Level::DEBUG,
{ $($field)+ },
$($arg)+
)
);
($($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::DEBUG,
{ $($k).+ = $($field)*}
)
);
(?$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::DEBUG,
{ ?$($k).+ = $($field)*}
)
);
(%$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::DEBUG,
{ %$($k).+ = $($field)*}
)
);
($($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::DEBUG,
{ $($k).+, $($field)*}
)
);
(?$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::DEBUG,
{ ?$($k).+, $($field)*}
)
);
(%$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::DEBUG,
{ %$($k).+, $($field)*}
)
);
(?$($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::DEBUG,
{ ?$($k).+ }
)
);
(%$($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::DEBUG,
{ %$($k).+ }
)
);
($($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::DEBUG,
{ $($k).+ }
)
);
($($arg:tt)+) => (
$crate::event!(
target: module_path!(),
$crate::Level::DEBUG,
{},
$($arg)+
)
);
}
#[macro_export]
macro_rules! info {
(target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::INFO, { $($field)* }, $($arg)*)
);
(target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::INFO, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::INFO, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::INFO, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::INFO, {}, $($arg)+)
);
(parent: $parent:expr, { $($field:tt)+ }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::INFO,
{ $($field)+ },
$($arg)+
)
);
(parent: $parent:expr, $($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::INFO,
{ $($k).+ = $($field)*}
)
);
(parent: $parent:expr, ?$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::INFO,
{ ?$($k).+ = $($field)*}
)
);
(parent: $parent:expr, %$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::INFO,
{ %$($k).+ = $($field)*}
)
);
(parent: $parent:expr, $($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::INFO,
{ $($k).+, $($field)*}
)
);
(parent: $parent:expr, ?$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::INFO,
{ ?$($k).+, $($field)*}
)
);
(parent: $parent:expr, %$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::INFO,
{ %$($k).+, $($field)*}
)
);
(parent: $parent:expr, $($arg:tt)+) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::INFO,
{},
$($arg)+
)
);
(target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => (
$crate::event!(target: $target, $crate::Level::INFO, { $($field)* }, $($arg)*)
);
(target: $target:expr, $($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::INFO, { $($k).+ $($field)+ })
);
(target: $target:expr, ?$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::INFO, { $($k).+ $($field)+ })
);
(target: $target:expr, %$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::INFO, { $($k).+ $($field)+ })
);
(target: $target:expr, $($arg:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::INFO, {}, $($arg)+)
);
({ $($field:tt)+ }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
$crate::Level::INFO,
{ $($field)+ },
$($arg)+
)
);
($($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::INFO,
{ $($k).+ = $($field)*}
)
);
(?$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::INFO,
{ ?$($k).+ = $($field)*}
)
);
(%$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::TRACE,
{ %$($k).+ = $($field)*}
)
);
($($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::INFO,
{ $($k).+, $($field)*}
)
);
(?$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::INFO,
{ ?$($k).+, $($field)*}
)
);
(%$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::INFO,
{ %$($k).+, $($field)*}
)
);
(?$($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::INFO,
{ ?$($k).+ }
)
);
(%$($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::INFO,
{ %$($k).+ }
)
);
($($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::INFO,
{ $($k).+ }
)
);
($($arg:tt)+) => (
$crate::event!(
target: module_path!(),
$crate::Level::INFO,
{},
$($arg)+
)
);
}
#[macro_export]
macro_rules! warn {
(target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::WARN, { $($field)* }, $($arg)*)
);
(target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::WARN, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::WARN, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::WARN, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::WARN, {}, $($arg)+)
);
(parent: $parent:expr, { $($field:tt)+ }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::WARN,
{ $($field)+ },
$($arg)+
)
);
(parent: $parent:expr, $($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::WARN,
{ $($k).+ = $($field)*}
)
);
(parent: $parent:expr, ?$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::WARN,
{ ?$($k).+ = $($field)*}
)
);
(parent: $parent:expr, %$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::WARN,
{ %$($k).+ = $($field)*}
)
);
(parent: $parent:expr, $($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::WARN,
{ $($k).+, $($field)*}
)
);
(parent: $parent:expr, ?$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::WARN,
{ ?$($k).+, $($field)*}
)
);
(parent: $parent:expr, %$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::WARN,
{ %$($k).+, $($field)*}
)
);
(parent: $parent:expr, $($arg:tt)+) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::WARN,
{},
$($arg)+
)
);
(target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => (
$crate::event!(target: $target, $crate::Level::WARN, { $($field)* }, $($arg)*)
);
(target: $target:expr, $($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::WARN, { $($k).+ $($field)+ })
);
(target: $target:expr, ?$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::WARN, { $($k).+ $($field)+ })
);
(target: $target:expr, %$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::WARN, { $($k).+ $($field)+ })
);
(target: $target:expr, $($arg:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::WARN, {}, $($arg)+)
);
({ $($field:tt)+ }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
$crate::Level::WARN,
{ $($field)+ },
$($arg)+
)
);
($($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::WARN,
{ $($k).+ = $($field)*}
)
);
(?$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::WARN,
{ ?$($k).+ = $($field)*}
)
);
(%$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::TRACE,
{ %$($k).+ = $($field)*}
)
);
($($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::WARN,
{ $($k).+, $($field)*}
)
);
(?$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::WARN,
{ ?$($k).+, $($field)*}
)
);
(%$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::WARN,
{ %$($k).+, $($field)*}
)
);
(?$($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::WARN,
{ ?$($k).+ }
)
);
(%$($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::WARN,
{ %$($k).+ }
)
);
($($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::WARN,
{ $($k).+ }
)
);
($($arg:tt)+) => (
$crate::event!(
target: module_path!(),
$crate::Level::WARN,
{},
$($arg)+
)
);
}
#[macro_export]
macro_rules! error {
(target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::ERROR, { $($field)* }, $($arg)*)
);
(target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::ERROR, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::ERROR, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::ERROR, { $($k).+ $($field)+ })
);
(target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) => (
$crate::event!(target: $target, parent: $parent, $crate::Level::ERROR, {}, $($arg)+)
);
(parent: $parent:expr, { $($field:tt)+ }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::ERROR,
{ $($field)+ },
$($arg)+
)
);
(parent: $parent:expr, $($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::ERROR,
{ $($k).+ = $($field)*}
)
);
(parent: $parent:expr, ?$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::ERROR,
{ ?$($k).+ = $($field)*}
)
);
(parent: $parent:expr, %$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::ERROR,
{ %$($k).+ = $($field)*}
)
);
(parent: $parent:expr, $($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::ERROR,
{ $($k).+, $($field)*}
)
);
(parent: $parent:expr, ?$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::ERROR,
{ ?$($k).+, $($field)*}
)
);
(parent: $parent:expr, %$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::ERROR,
{ %$($k).+, $($field)*}
)
);
(parent: $parent:expr, $($arg:tt)+) => (
$crate::event!(
target: module_path!(),
parent: $parent,
$crate::Level::ERROR,
{},
$($arg)+
)
);
(target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => (
$crate::event!(target: $target, $crate::Level::ERROR, { $($field)* }, $($arg)*)
);
(target: $target:expr, $($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::ERROR, { $($k).+ $($field)+ })
);
(target: $target:expr, ?$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::ERROR, { $($k).+ $($field)+ })
);
(target: $target:expr, %$($k:ident).+ $($field:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::ERROR, { $($k).+ $($field)+ })
);
(target: $target:expr, $($arg:tt)+ ) => (
$crate::event!(target: $target, $crate::Level::ERROR, {}, $($arg)+)
);
({ $($field:tt)+ }, $($arg:tt)+ ) => (
$crate::event!(
target: module_path!(),
$crate::Level::ERROR,
{ $($field)+ },
$($arg)+
)
);
($($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::ERROR,
{ $($k).+ = $($field)*}
)
);
(?$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::ERROR,
{ ?$($k).+ = $($field)*}
)
);
(%$($k:ident).+ = $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::TRACE,
{ %$($k).+ = $($field)*}
)
);
($($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::ERROR,
{ $($k).+, $($field)*}
)
);
(?$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::ERROR,
{ ?$($k).+, $($field)*}
)
);
(%$($k:ident).+, $($field:tt)*) => (
$crate::event!(
target: module_path!(),
$crate::Level::ERROR,
{ %$($k).+, $($field)*}
)
);
(?$($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::ERROR,
{ ?$($k).+ }
)
);
(%$($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::ERROR,
{ %$($k).+ }
)
);
($($k:ident).+) => (
$crate::event!(
target: module_path!(),
$crate::Level::ERROR,
{ $($k).+ }
)
);
($($arg:tt)+) => (
$crate::event!(
target: module_path!(),
$crate::Level::ERROR,
{},
$($arg)+
)
);
}
#[doc(hidden)]
#[macro_export]
macro_rules! callsite {
(name: $name:expr, kind: $kind:expr, fields: $($fields:tt)*) => {{
$crate::callsite! {
name: $name,
kind: $kind,
target: module_path!(),
level: $crate::Level::TRACE,
fields: $($fields)*
}
}};
(
name: $name:expr,
kind: $kind:expr,
level: $lvl:expr,
fields: $($fields:tt)*
) => {{
$crate::callsite! {
name: $name,
kind: $kind,
target: module_path!(),
level: $lvl,
fields: $($fields)*
}
}};
(
name: $name:expr,
kind: $kind:expr,
target: $target:expr,
level: $lvl:expr,
fields: $($fields:tt)*
) => {{
use $crate::__macro_support::MacroCallsite;
static META: $crate::Metadata<'static> = {
$crate::metadata! {
name: $name,
target: $target,
level: $lvl,
fields: $crate::fieldset!( $($fields)* ),
callsite: &CALLSITE,
kind: $kind,
}
};
static CALLSITE: MacroCallsite = MacroCallsite::new(&META);
CALLSITE.register();
&CALLSITE
}};
}
#[doc(hidden)]
#[macro_export]
macro_rules! callsite2 {
(name: $name:expr, kind: $kind:expr, fields: $($fields:tt)*) => {{
$crate::callsite2! {
name: $name,
kind: $kind,
target: module_path!(),
level: $crate::Level::TRACE,
fields: $($fields)*
}
}};
(
name: $name:expr,
kind: $kind:expr,
level: $lvl:expr,
fields: $($fields:tt)*
) => {{
$crate::callsite2! {
name: $name,
kind: $kind,
target: module_path!(),
level: $lvl,
fields: $($fields)*
}
}};
(
name: $name:expr,
kind: $kind:expr,
target: $target:expr,
level: $lvl:expr,
fields: $($fields:tt)*
) => {{
use $crate::__macro_support::MacroCallsite;
static META: $crate::Metadata<'static> = {
$crate::metadata! {
name: $name,
target: $target,
level: $lvl,
fields: $crate::fieldset!( $($fields)* ),
callsite: &CALLSITE,
kind: $kind,
}
};
MacroCallsite::new(&META)
}};
}
#[macro_export]
#[doc(hidden)]
macro_rules! level_enabled {
($lvl:expr) => {
$lvl <= $crate::level_filters::STATIC_MAX_LEVEL
&& $lvl <= $crate::level_filters::LevelFilter::current()
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! valueset {
(@ { $(,)* $($val:expr),* $(,)* }, $next:expr $(,)*) => {
&[ $($val),* ]
};
(@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = ?$val:expr, $($rest:tt)*) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&debug(&$val) as &Value)) },
$next,
$($rest)*
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = %$val:expr, $($rest:tt)*) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&display(&$val) as &Value)) },
$next,
$($rest)*
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = $val:expr, $($rest:tt)*) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&$val as &Value)) },
$next,
$($rest)*
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+, $($rest:tt)*) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&$($k).+ as &Value)) },
$next,
$($rest)*
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, ?$($k:ident).+, $($rest:tt)*) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&debug(&$($k).+) as &Value)) },
$next,
$($rest)*
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, %$($k:ident).+, $($rest:tt)*) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&display(&$($k).+) as &Value)) },
$next,
$($rest)*
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = ?$val:expr) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&debug(&$val) as &Value)) },
$next,
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = %$val:expr) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&display(&$val) as &Value)) },
$next,
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = $val:expr) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&$val as &Value)) },
$next,
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $($k:ident).+) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&$($k).+ as &Value)) },
$next,
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, ?$($k:ident).+) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&debug(&$($k).+) as &Value)) },
$next,
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, %$($k:ident).+) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&display(&$($k).+) as &Value)) },
$next,
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = ?$val:expr, $($rest:tt)*) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&debug(&$val) as &Value)) },
$next,
$($rest)*
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = %$val:expr, $($rest:tt)*) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&display(&$val) as &Value)) },
$next,
$($rest)*
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = $val:expr, $($rest:tt)*) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&$val as &Value)) },
$next,
$($rest)*
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = ?$val:expr) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&debug(&$val) as &Value)) },
$next,
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = %$val:expr) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&display(&$val) as &Value)) },
$next,
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $k:literal = $val:expr) => {
$crate::valueset!(
@ { $($out),*, (&$next, Some(&$val as &Value)) },
$next,
)
};
(@ { $(,)* $($out:expr),* }, $next:expr, $($rest:tt)+) => {
$crate::valueset!(@ { (&$next, Some(&format_args!($($rest)+) as &Value)), $($out),* }, $next, )
};
($fields:expr, $($kvs:tt)+) => {
{
#[allow(unused_imports)]
use $crate::field::{debug, display, Value};
let mut iter = $fields.iter();
$fields.value_set($crate::valueset!(
@ { },
iter.next().expect("FieldSet corrupted (this is a bug)"),
$($kvs)+
))
}
};
($fields:expr,) => {
{
$fields.value_set(&[])
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! fieldset {
(@ { $(,)* $($out:expr),* $(,)* } $(,)*) => {
&[ $($out),* ]
};
(@ { $(,)* $($out:expr),* } $($k:ident).+ = ?$val:expr, $($rest:tt)*) => {
$crate::fieldset!(@ { $($out),*, $crate::__tracing_stringify!($($k).+) } $($rest)*)
};
(@ { $(,)* $($out:expr),* } $($k:ident).+ = %$val:expr, $($rest:tt)*) => {
$crate::fieldset!(@ { $($out),*, $crate::__tracing_stringify!($($k).+) } $($rest)*)
};
(@ { $(,)* $($out:expr),* } $($k:ident).+ = $val:expr, $($rest:tt)*) => {
$crate::fieldset!(@ { $($out),*, $crate::__tracing_stringify!($($k).+) } $($rest)*)
};
(@ { $(,)* $($out:expr),* } ?$($k:ident).+, $($rest:tt)*) => {
$crate::fieldset!(@ { $($out),*, $crate::__tracing_stringify!($($k).+) } $($rest)*)
};
(@ { $(,)* $($out:expr),* } %$($k:ident).+, $($rest:tt)*) => {
$crate::fieldset!(@ { $($out),*, $crate::__tracing_stringify!($($k).+) } $($rest)*)
};
(@ { $(,)* $($out:expr),* } $($k:ident).+, $($rest:tt)*) => {
$crate::fieldset!(@ { $($out),*, $crate::__tracing_stringify!($($k).+) } $($rest)*)
};
(@ { $(,)* $($out:expr),* } $k:literal = ?$val:expr, $($rest:tt)*) => {
$crate::fieldset!(@ { $($out),*, $k } $($rest)*)
};
(@ { $(,)* $($out:expr),* } $k:literal = %$val:expr, $($rest:tt)*) => {
$crate::fieldset!(@ { $($out),*, $k } $($rest)*)
};
(@ { $(,)* $($out:expr),* } $k:literal = $val:expr, $($rest:tt)*) => {
$crate::fieldset!(@ { $($out),*, $k } $($rest)*)
};
(@ { $(,)* $($out:expr),* } $($rest:tt)+) => {
$crate::fieldset!(@ { "message", $($out),*, })
};
($($args:tt)*) => {
$crate::fieldset!(@ { } $($args)*,)
};
}
#[cfg(feature = "log")]
#[doc(hidden)]
#[macro_export]
macro_rules! level_to_log {
($level:expr) => {
match $level {
$crate::Level::ERROR => $crate::log::Level::Error,
$crate::Level::WARN => $crate::log::Level::Warn,
$crate::Level::INFO => $crate::log::Level::Info,
$crate::Level::DEBUG => $crate::log::Level::Debug,
_ => $crate::log::Level::Trace,
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __tracing_stringify {
($s:expr) => {
stringify!($s)
};
}
#[cfg(not(feature = "log"))]
#[doc(hidden)]
#[macro_export]
macro_rules! __tracing_log {
(target: $target:expr, $level:expr, $($field:tt)+ ) => {};
}
#[cfg(feature = "log")]
#[doc(hidden)]
#[macro_export]
macro_rules! __mk_format_string {
(@ { $(,)* $($out:expr),* $(,)* } $(,)*) => {
concat!( $($out),*)
};
(@ { $(,)* $($out:expr),* }, ?$($k:ident).+, $($rest:tt)*) => {
$crate::__mk_format_string!(@ { $($out),*, $crate::__tracing_stringify!($($k).+), "={:?} " }, $($rest)*)
};
(@ { $(,)* $($out:expr),* }, %$($k:ident).+, $($rest:tt)*) => {
$crate::__mk_format_string!(@ { $($out),*, $crate::__tracing_stringify!($($k).+), "={} " }, $($rest)*)
};
(@ { $(,)* $($out:expr),* }, $($k:ident).+, $($rest:tt)*) => {
$crate::__mk_format_string!(@ { $($out),*, $crate::__tracing_stringify!($($k).+), "={:?} " }, $($rest)*)
};
(@ { $(,)* $($out:expr),* }, message = $val:expr, $($rest:tt)*) => {
$crate::__mk_format_string!(@ { $($out),*, "{} " }, $($rest)*)
};
(@ { $(,)* $($out:expr),* }, $($k:ident).+ = ?$val:expr, $($rest:tt)*) => {
$crate::__mk_format_string!(@ { $($out),*, $crate::__tracing_stringify!($($k).+), "={:?} " }, $($rest)*)
};
(@ { $(,)* $($out:expr),* }, $($k:ident).+ = %$val:expr, $($rest:tt)*) => {
$crate::__mk_format_string!(@ { $($out),*, $crate::__tracing_stringify!($($k).+), "={} " }, $($rest)*)
};
(@ { $(,)* $($out:expr),* }, $($k:ident).+ = $val:expr, $($rest:tt)*) => {
$crate::__mk_format_string!(@ { $($out),*, $crate::__tracing_stringify!($($k).+), "={:?} " }, $($rest)*)
};
(@ { $(,)* $($out:expr),* }, $($rest:tt)+) => {
$crate::__mk_format_string!(@ { "{} ", $($out),* }, )
};
($($kvs:tt)+) => {
$crate::__mk_format_string!(@ { }, $($kvs)+,)
};
() => {
""
}
}
#[cfg(feature = "log")]
#[doc(hidden)]
#[macro_export]
macro_rules! __mk_format_args {
(@ { $(,)* $($out:expr),* $(,)* }, $fmt:expr, fields: $(,)*) => {
format_args!($fmt, $($out),*)
};
(@ { $(,)* $($out:expr),* }, $fmt:expr, fields: $($k:ident).+ = ?$val:expr $(,)*) => {
$crate::__mk_format_args!(@ { $($out),*, $val }, $fmt, fields: )
};
(@ { $(,)* $($out:expr),* }, $fmt:expr, fields: $($k:ident).+ = %$val:expr $(,)*) => {
$crate::__mk_format_args!(@ { $($out),*, $val }, $fmt, fields: )
};
(@ { $(,)* $($out:expr),* }, $fmt:expr, fields: $($k:ident).+ = $val:expr $(,)*) => {
$crate::__mk_format_args!(@ { $($out),*, $val }, $fmt, fields: )
};
(@ { $(,)* $($out:expr),* }, $fmt:expr, fields: ?$($k:ident).+ $(,)*) => {
$crate::__mk_format_args!(@ { $($out),*, &$($k).+ }, $fmt, fields:)
};
(@ { $(,)* $($out:expr),* }, $fmt:expr, fields: %$($k:ident).+ $(,)*) => {
$crate::__mk_format_args!(@ { $($out),*, &$($k).+ }, $fmt, fields: )
};
(@ { $(,)* $($out:expr),* }, $fmt:expr, fields: $($k:ident).+ $(,)*) => {
$crate::__mk_format_args!(@ { $($out),*, &$($k).+ }, $fmt, fields: )
};
(@ { $(,)* $($out:expr),* }, $fmt:expr, fields: $($k:ident).+ = ?$val:expr, $($rest:tt)+) => {
$crate::__mk_format_args!(@ { $($out),*, $val }, $fmt, fields: $($rest)+)
};
(@ { $(,)* $($out:expr),* }, $fmt:expr, fields: $($k:ident).+ = %$val:expr, $($rest:tt)+) => {
$crate::__mk_format_args!(@ { $($out),*, $val }, $fmt, fields: $($rest)+)
};
(@ { $(,)* $($out:expr),* }, $fmt:expr, fields: $($k:ident).+ = $val:expr, $($rest:tt)+) => {
$crate::__mk_format_args!(@ { $($out),*, $val }, $fmt, fields: $($rest)+)
};
(@ { $(,)* $($out:expr),* }, $fmt:expr, fields: ?$($k:ident).+, $($rest:tt)+) => {
$crate::__mk_format_args!(@ { $($out),*, &$($k).+ }, $fmt, fields: $($rest)+)
};
(@ { $(,)* $($out:expr),* }, $fmt:expr, fields: %$($k:ident).+, $($rest:tt)+) => {
$crate::__mk_format_args!(@ { $($out),*, &$($k).+ }, $fmt, fields: $($rest)+)
};
(@ { $(,)* $($out:expr),* }, $fmt:expr, fields: $($k:ident).+, $($rest:tt)+) => {
$crate::__mk_format_args!(@ { $($out),*, &$($k).+ }, $fmt, fields: $($rest)+)
};
(@ { $(,)* $($out:expr),* }, $fmt:expr, fields: $($rest:tt)+) => {
$crate::__mk_format_args!(@ { format_args!($($rest)+), $($out),* }, $fmt, fields: )
};
($($kv:tt)*) => {
{
#[allow(unused_imports)]
use $crate::field::{debug, display};
$crate::__mk_format_args!(@ { }, $crate::__mk_format_string!($($kv)*), fields: $($kv)*)
}
};
}
#[cfg(feature = "log")]
#[doc(hidden)]
#[macro_export]
macro_rules! __tracing_log {
(target: $target:expr, $level:expr, $($field:tt)+ ) => {
$crate::if_log_enabled! {{
use $crate::log;
let level = $crate::level_to_log!($level);
if level <= log::STATIC_MAX_LEVEL && level <= log::max_level() {
let log_meta = log::Metadata::builder()
.level(level)
.target($target)
.build();
let logger = log::logger();
if logger.enabled(&log_meta) {
logger.log(&log::Record::builder()
.file(Some(file!()))
.module_path(Some(module_path!()))
.line(Some(line!()))
.metadata(log_meta)
.args($crate::__mk_format_args!($($field)+))
.build());
}
}
}}
};
}
#[cfg(not(feature = "log"))]
#[doc(hidden)]
#[macro_export]
macro_rules! if_log_enabled {
($e:expr;) => {
$crate::if_log_enabled! { $e }
};
($if_log:block) => {
$crate::if_log_enabled! { $if_log else {} }
};
($if_log:block else $else_block:block) => {
$else_block
};
}
#[cfg(all(feature = "log", not(feature = "log-always")))]
#[doc(hidden)]
#[macro_export]
macro_rules! if_log_enabled {
($e:expr;) => {
$crate::if_log_enabled! { $e }
};
($if_log:block) => {
$crate::if_log_enabled! { $if_log else {} }
};
($if_log:block else $else_block:block) => {
if !$crate::dispatcher::has_been_set() {
$if_log
} else {
$else_block
}
};
}
#[cfg(all(feature = "log", feature = "log-always"))]
#[doc(hidden)]
#[macro_export]
macro_rules! if_log_enabled {
($e:expr;) => {
$crate::if_log_enabled! { $e }
};
($if_log:block) => {
$crate::if_log_enabled! { $if_log else {} }
};
($if_log:block else $else_block:block) => {
#[allow(unused_braces)]
$if_log
};
}