Skip to content

Commit

Permalink
macros: Fix non-simple macro usage without message
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Turbo87 committed Feb 14, 2024
1 parent baeba47 commit 5cb8922
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 40 deletions.
80 changes: 40 additions & 40 deletions tracing/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1307,10 +1307,10 @@ macro_rules! trace {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -1324,10 +1324,10 @@ macro_rules! trace {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -1341,10 +1341,10 @@ macro_rules! trace {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -1358,10 +1358,10 @@ macro_rules! trace {
$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)+ })
$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)+ })
$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)+)
Expand Down Expand Up @@ -1584,10 +1584,10 @@ macro_rules! debug {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -1601,10 +1601,10 @@ macro_rules! debug {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -1618,10 +1618,10 @@ macro_rules! debug {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -1635,10 +1635,10 @@ macro_rules! debug {
$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)+ })
$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)+ })
$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)+)
Expand Down Expand Up @@ -1872,10 +1872,10 @@ macro_rules! info {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -1889,10 +1889,10 @@ macro_rules! info {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -1906,10 +1906,10 @@ macro_rules! info {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -1923,10 +1923,10 @@ macro_rules! info {
$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)+ })
$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)+ })
$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)+)
Expand Down Expand Up @@ -2153,10 +2153,10 @@ macro_rules! warn {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -2170,10 +2170,10 @@ macro_rules! warn {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -2187,10 +2187,10 @@ macro_rules! warn {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -2204,10 +2204,10 @@ macro_rules! warn {
$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)+ })
$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)+ })
$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)+)
Expand Down Expand Up @@ -2430,10 +2430,10 @@ macro_rules! error {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -2447,10 +2447,10 @@ macro_rules! error {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -2464,10 +2464,10 @@ macro_rules! error {
$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)+ })
$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)+ })
$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)+)
Expand All @@ -2481,10 +2481,10 @@ macro_rules! error {
$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)+ })
$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)+ })
$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)+)
Expand Down
Loading

0 comments on commit 5cb8922

Please sign in to comment.