diff options
Diffstat (limited to 'vendor/gix-trace/src/disabled.rs')
-rw-r--r-- | vendor/gix-trace/src/disabled.rs | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/vendor/gix-trace/src/disabled.rs b/vendor/gix-trace/src/disabled.rs new file mode 100644 index 000000000..a4a12787c --- /dev/null +++ b/vendor/gix-trace/src/disabled.rs @@ -0,0 +1,105 @@ +/// A workaround for a clippy warning +#[doc(hidden)] +#[derive(Clone)] +pub struct Span; + +impl Span { + /// A no-op + pub fn record<V>(&self, _field: &str, _value: V) -> &Self { + self + } +} + +/// A macro to create a span. +#[macro_export] +macro_rules! span { + (target: $target:expr, $lvl:expr, $name:expr, $($fields:tt)*) => { + $crate::Span + }; + (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, + ) + }; +} + +/// Create an event with the given level. +#[macro_export] +macro_rules! event { + (target: $target:expr, $lvl:expr, { $($fields:tt)* } )=> ( + {} + ); + (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)+ }) + ); + ( $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)+ }) + ); +} |