From 0e3577f6f3995b92accee21e0737c25ef0f1953c Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 16 Feb 2024 20:48:38 +0100 Subject: [PATCH] macros: Fix non-simple macro usage without message (#2879) If something like `warn!(?foo)` and `warn!(name: "foo", ?foo)` works, then `warn!(name: "foo", target: "foo_events", ?foo)` should arguably also work. Before this change the more complicated variants of the macros however required a message argument, due to the usage of the `+` specifier in the macro definitions. This commit changes the `+` (1 or more) to `*` (0 or more), which matches how the `field` tokens are used in the simpler variants of the macro. --- tracing/src/macros.rs | 240 ++++++++++++++++++++-------------------- tracing/tests/macros.rs | 15 +++ 2 files changed, 135 insertions(+), 120 deletions(-) diff --git a/tracing/src/macros.rs b/tracing/src/macros.rs index ca841275a..9f6bd7670 100644 --- a/tracing/src/macros.rs +++ b/tracing/src/macros.rs @@ -1303,14 +1303,14 @@ macro_rules! trace { (name: $name:expr, target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::TRACE, { $($field)* }, $($arg)*) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::TRACE, { $($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::TRACE, { $($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::TRACE, { ?$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::TRACE, { ?$($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::TRACE, { %$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::TRACE, { %$($k).+ $($field)* }) ); (name: $name:expr, target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::TRACE, {}, $($arg)+) @@ -1320,14 +1320,14 @@ macro_rules! trace { (name: $name:expr, target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, target: $target, $crate::Level::TRACE, { $($field)* }, $($arg)*) ); - (name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::TRACE, { $($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::TRACE, { $($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::TRACE, { ?$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::TRACE, { ?$($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::TRACE, { %$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::TRACE, { %$($k).+ $($field)* }) ); (name: $name:expr, target: $target:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, target: $target, $crate::Level::TRACE, {}, $($arg)+) @@ -1337,14 +1337,14 @@ 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, ?$($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)+) @@ -1354,14 +1354,14 @@ macro_rules! trace { (name: $name:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, parent: $parent, $crate::Level::TRACE, { $($field)* }, $($arg)*) ); - (name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::TRACE, { $($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::TRACE, { $($k).+ $($field)* }) ); - (name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::TRACE, { ?$($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::TRACE, { ?$($k).+ $($field)* }) ); - (name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::TRACE, { %$($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::TRACE, { %$($k).+ $($field)* }) ); (name: $name:expr, parent: $parent:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, parent: $parent, $crate::Level::TRACE, {}, $($arg)+) @@ -1580,14 +1580,14 @@ macro_rules! debug { (name: $name:expr, target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::DEBUG, { $($field)* }, $($arg)*) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::DEBUG, { $($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::DEBUG, { $($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::DEBUG, { ?$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::DEBUG, { ?$($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::DEBUG, { %$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::DEBUG, { %$($k).+ $($field)* }) ); (name: $name:expr, target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::DEBUG, {}, $($arg)+) @@ -1597,14 +1597,14 @@ macro_rules! debug { (name: $name:expr, target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, target: $target, $crate::Level::DEBUG, { $($field)* }, $($arg)*) ); - (name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::DEBUG, { $($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::DEBUG, { $($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::DEBUG, { ?$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::DEBUG, { ?$($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::DEBUG, { %$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::DEBUG, { %$($k).+ $($field)* }) ); (name: $name:expr, target: $target:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, target: $target, $crate::Level::DEBUG, {}, $($arg)+) @@ -1614,14 +1614,14 @@ 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, ?$($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)+) @@ -1631,14 +1631,14 @@ macro_rules! debug { (name: $name:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, parent: $parent, $crate::Level::DEBUG, { $($field)* }, $($arg)*) ); - (name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::DEBUG, { $($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::DEBUG, { $($k).+ $($field)* }) ); - (name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::DEBUG, { ?$($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::DEBUG, { ?$($k).+ $($field)* }) ); - (name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::DEBUG, { %$($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::DEBUG, { %$($k).+ $($field)* }) ); (name: $name:expr, parent: $parent:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, parent: $parent, $crate::Level::DEBUG, {}, $($arg)+) @@ -1868,14 +1868,14 @@ macro_rules! info { (name: $name:expr, target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::INFO, { $($field)* }, $($arg)*) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::INFO, { $($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::INFO, { $($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::INFO, { ?$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::INFO, { ?$($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::INFO, { %$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::INFO, { %$($k).+ $($field)* }) ); (name: $name:expr, target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::INFO, {}, $($arg)+) @@ -1885,14 +1885,14 @@ macro_rules! info { (name: $name:expr, target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, target: $target, $crate::Level::INFO, { $($field)* }, $($arg)*) ); - (name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::INFO, { $($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::INFO, { $($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::INFO, { ?$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::INFO, { ?$($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::INFO, { %$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::INFO, { %$($k).+ $($field)* }) ); (name: $name:expr, target: $target:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, target: $target, $crate::Level::INFO, {}, $($arg)+) @@ -1902,14 +1902,14 @@ 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, ?$($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)+) @@ -1919,14 +1919,14 @@ macro_rules! info { (name: $name:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, parent: $parent, $crate::Level::INFO, { $($field)* }, $($arg)*) ); - (name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::INFO, { $($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::INFO, { $($k).+ $($field)* }) ); - (name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::INFO, { ?$($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::INFO, { ?$($k).+ $($field)* }) ); - (name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::INFO, { %$($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::INFO, { %$($k).+ $($field)* }) ); (name: $name:expr, parent: $parent:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, parent: $parent, $crate::Level::INFO, {}, $($arg)+) @@ -2149,14 +2149,14 @@ macro_rules! warn { (name: $name:expr, target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::WARN, { $($field)* }, $($arg)*) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::WARN, { $($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::WARN, { $($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::WARN, { ?$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::WARN, { ?$($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::WARN, { %$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::WARN, { %$($k).+ $($field)* }) ); (name: $name:expr, target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::WARN, {}, $($arg)+) @@ -2166,14 +2166,14 @@ macro_rules! warn { (name: $name:expr, target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, target: $target, $crate::Level::WARN, { $($field)* }, $($arg)*) ); - (name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::WARN, { $($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::WARN, { $($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::WARN, { ?$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::WARN, { ?$($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::WARN, { %$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::WARN, { %$($k).+ $($field)* }) ); (name: $name:expr, target: $target:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, target: $target, $crate::Level::WARN, {}, $($arg)+) @@ -2183,14 +2183,14 @@ 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, ?$($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)+) @@ -2200,14 +2200,14 @@ macro_rules! warn { (name: $name:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, parent: $parent, $crate::Level::WARN, { $($field)* }, $($arg)*) ); - (name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::WARN, { $($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::WARN, { $($k).+ $($field)* }) ); - (name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::WARN, { ?$($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::WARN, { ?$($k).+ $($field)* }) ); - (name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::WARN, { %$($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::WARN, { %$($k).+ $($field)* }) ); (name: $name:expr, parent: $parent:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, parent: $parent, $crate::Level::WARN, {}, $($arg)+) @@ -2426,14 +2426,14 @@ macro_rules! error { (name: $name:expr, target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::ERROR, { $($field)* }, $($arg)*) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::ERROR, { $($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::ERROR, { $($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::ERROR, { ?$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::ERROR, { ?$($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::ERROR, { %$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::ERROR, { %$($k).+ $($field)* }) ); (name: $name:expr, target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, target: $target, parent: $parent, $crate::Level::ERROR, {}, $($arg)+) @@ -2443,14 +2443,14 @@ macro_rules! error { (name: $name:expr, target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, target: $target, $crate::Level::ERROR, { $($field)* }, $($arg)*) ); - (name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::ERROR, { $($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::ERROR, { $($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::ERROR, { ?$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::ERROR, { ?$($k).+ $($field)* }) ); - (name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, target: $target, $crate::Level::ERROR, { %$($k).+ $($field)+ }) + (name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, target: $target, $crate::Level::ERROR, { %$($k).+ $($field)* }) ); (name: $name:expr, target: $target:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, target: $target, $crate::Level::ERROR, {}, $($arg)+) @@ -2460,14 +2460,14 @@ 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, ?$($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)+) @@ -2477,14 +2477,14 @@ macro_rules! error { (name: $name:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) => ( $crate::event!(name: $name, parent: $parent, $crate::Level::ERROR, { $($field)* }, $($arg)*) ); - (name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::ERROR, { $($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::ERROR, { $($k).+ $($field)* }) ); - (name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::ERROR, { ?$($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::ERROR, { ?$($k).+ $($field)* }) ); - (name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)+ ) => ( - $crate::event!(name: $name, parent: $parent, $crate::Level::ERROR, { %$($k).+ $($field)+ }) + (name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) => ( + $crate::event!(name: $name, parent: $parent, $crate::Level::ERROR, { %$($k).+ $($field)* }) ); (name: $name:expr, parent: $parent:expr, $($arg:tt)+ ) => ( $crate::event!(name: $name, parent: $parent, $crate::Level::ERROR, {}, $($arg)+) diff --git a/tracing/tests/macros.rs b/tracing/tests/macros.rs index e9966a546..8d58bf610 100644 --- a/tracing/tests/macros.rs +++ b/tracing/tests/macros.rs @@ -591,6 +591,9 @@ fn trace() { trace!(target: "foo_events", ?foo, true, "message"); trace!(target: "foo_events", %foo, true, "message"); trace!(target: "foo_events", foo, true, "message"); + trace!(name: "foo", target: "foo_events", ?foo); + trace!(name: "foo", target: "foo_events", %foo); + trace!(name: "foo", target: "foo_events", foo); let foo = DisplayDebug; trace!(?foo); trace!(%foo); @@ -648,6 +651,9 @@ fn debug() { debug!(target: "foo_events", ?foo, true, "message"); debug!(target: "foo_events", %foo, true, "message"); debug!(target: "foo_events", foo, true, "message"); + debug!(name: "foo", target: "foo_events", ?foo); + debug!(name: "foo", target: "foo_events", %foo); + debug!(name: "foo", target: "foo_events", foo); let foo = DisplayDebug; debug!(?foo); debug!(%foo); @@ -705,6 +711,9 @@ fn info() { info!(target: "foo_events", ?foo, true, "message"); info!(target: "foo_events", %foo, true, "message"); info!(target: "foo_events", foo, true, "message"); + info!(name: "foo", target: "foo_events", ?foo); + info!(name: "foo", target: "foo_events", %foo); + info!(name: "foo", target: "foo_events", foo); let foo = DisplayDebug; info!(?foo); info!(%foo); @@ -762,6 +771,9 @@ fn warn() { warn!(target: "foo_events", ?foo, true, "message"); warn!(target: "foo_events", %foo, true, "message"); warn!(target: "foo_events", foo, true, "message"); + warn!(name: "foo", target: "foo_events", ?foo); + warn!(name: "foo", target: "foo_events", %foo); + warn!(name: "foo", target: "foo_events", foo); let foo = DisplayDebug; warn!(?foo); warn!(%foo); @@ -819,6 +831,9 @@ fn error() { error!(target: "foo_events", ?foo, true, "message"); error!(target: "foo_events", %foo, true, "message"); error!(target: "foo_events", foo, true, "message"); + error!(name: "foo", target: "foo_events", ?foo); + error!(name: "foo", target: "foo_events", %foo); + error!(name: "foo", target: "foo_events", foo); let foo = DisplayDebug; error!(?foo); error!(%foo);