Skip to content

Commit 76848eb

Browse files
Mododohds
authored andcommitted
tracing: fix "name / parent" variant of event!
In the case of an event with a name and a parent, the change in #2083 to use a free function instead of a method for `is_enabled` was not applied. This particular variant was also not covered by any tests, which is how this error slipped through CI. This change fixes the `is_enabled` call and adds additional test coverage for this macros case.
1 parent 15600a3 commit 76848eb

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

tracing/src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ macro_rules! event {
759759

760760
let enabled = $crate::level_enabled!($lvl) && {
761761
let interest = __CALLSITE.interest();
762-
!interest.is_never() && __CALLSITE.is_enabled(interest)
762+
!interest.is_never() && $crate::__macro_support::__is_enabled(__CALLSITE.metadata(), interest)
763763
};
764764
if enabled {
765765
(|value_set: $crate::field::ValueSet| {

tracing/tests/macros.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,13 @@ fn locals_no_message() {
520520
private_data,
521521
?data,
522522
);
523+
event!(
524+
name: "foo",
525+
parent: ::core::option::Option::None,
526+
Level::WARN,
527+
private_data,
528+
?data,
529+
);
523530
event!(
524531
target: "app_events",
525532
Level::WARN,
@@ -561,6 +568,7 @@ fn trace() {
561568
trace!({ foo = ?2, bar.baz = %78 }, "quux");
562569
trace!(name: "foo", foo = 3, bar.baz = 2, quux = false);
563570
trace!(name: "foo", target: "foo_events", foo = 3, bar.baz = 2, quux = false);
571+
trace!(name: "foo", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false);
564572
trace!(target: "foo_events", foo = 3, bar.baz = 2, quux = false);
565573
trace!(target: "foo_events", foo = 3, bar.baz = 3,);
566574
trace!(target: "foo_events", "foo");
@@ -605,6 +613,7 @@ fn debug() {
605613
debug!({ foo = ?2, bar.baz = %78 }, "quux");
606614
debug!(name: "foo", foo = 3, bar.baz = 2, quux = false);
607615
debug!(name: "foo", target: "foo_events", foo = 3, bar.baz = 2, quux = false);
616+
debug!(name: "foo", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false);
608617
debug!(target: "foo_events", foo = 3, bar.baz = 2, quux = false);
609618
debug!(target: "foo_events", foo = 3, bar.baz = 3,);
610619
debug!(target: "foo_events", "foo");
@@ -649,6 +658,7 @@ fn info() {
649658
info!({ foo = ?2, bar.baz = %78 }, "quux");
650659
info!(name: "foo", foo = 3, bar.baz = 2, quux = false);
651660
info!(name: "foo", target: "foo_events", foo = 3, bar.baz = 2, quux = false);
661+
info!(name: "foo", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false);
652662
info!(target: "foo_events", foo = 3, bar.baz = 2, quux = false);
653663
info!(target: "foo_events", foo = 3, bar.baz = 3,);
654664
info!(target: "foo_events", "foo");
@@ -693,6 +703,7 @@ fn warn() {
693703
warn!({ foo = ?2, bar.baz = %78 }, "quux");
694704
warn!(name: "foo", foo = 3, bar.baz = 2, quux = false);
695705
warn!(name: "foo", target: "foo_events", foo = 3, bar.baz = 2, quux = false);
706+
warn!(name: "foo", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false);
696707
warn!(target: "foo_events", foo = 3, bar.baz = 2, quux = false);
697708
warn!(target: "foo_events", foo = 3, bar.baz = 3,);
698709
warn!(target: "foo_events", "foo");
@@ -737,6 +748,7 @@ fn error() {
737748
error!({ foo = ?2, bar.baz = %78 }, "quux");
738749
error!(name: "foo", foo = 3, bar.baz = 2, quux = false);
739750
error!(name: "foo", target: "foo_events", foo = 3, bar.baz = 2, quux = false);
751+
error!(name: "foo", parent: ::core::option::Option::None, foo = 3, bar.baz = 2, quux = false);
740752
error!(target: "foo_events", foo = 3, bar.baz = 2, quux = false);
741753
error!(target: "foo_events", foo = 3, bar.baz = 3,);
742754
error!(target: "foo_events", "foo");

0 commit comments

Comments
 (0)