Skip to content

Commit 30fad6d

Browse files
miwigdavidbarsky
authored andcommitted
attributes: fix instrument with "log" feature (#2599)
## Motivation The instrument macro currently doesn't work with the "log" crate feature: #2585 ## Solution Change the generated code to create a span if either `tracing::if_log_enabled!` or `tracing::level_enabled!`. I'm not sure how to add a test for this or if this is the best solution. Fixes #2585
1 parent a1ce787 commit 30fad6d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tracing-attributes/src/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ fn gen_block<B: ToTokens>(
343343
// regression in case the level is enabled.
344344
let __tracing_attr_span;
345345
let __tracing_attr_guard;
346-
if tracing::level_enabled!(#level) {
346+
if tracing::level_enabled!(#level) || tracing::if_log_enabled!(#level, {true} else {false}) {
347347
__tracing_attr_span = #span;
348348
#follows_from
349349
__tracing_attr_guard = __tracing_attr_span.enter();

0 commit comments

Comments
 (0)