Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracing: attempt to monomorphize is_enabled call #787

Merged
merged 3 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tracing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,14 @@ pub mod __macro_support {
pub type Once = tracing_core::Once;
}

#[doc(hidden)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to consider making this public API, but I think that should be considered separately from fixing the monomorphization issue, so let's save that for another PR.

// resolves https://github.com/tokio-rs/tracing/issues/783 by forcing a monomorphization
// in tracing, not downstream crates.
#[inline]
pub fn is_enabled(meta: &crate::Metadata<'_>) -> bool {
davidbarsky marked this conversation as resolved.
Show resolved Hide resolved
crate::dispatcher::get_default(|current| current.enabled(meta))
}

mod sealed {
pub trait Sealed {}
}
6 changes: 3 additions & 3 deletions tracing/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ macro_rules! event {

if $crate::level_enabled!($lvl) {
#[allow(unused_imports)]
use $crate::{callsite, dispatcher, Event, field::{Value, ValueSet}};
use $crate::{callsite, Event, field::{Value, ValueSet}};
use $crate::callsite::Callsite;
let callsite = callsite! {
name: concat!(
Expand Down Expand Up @@ -584,7 +584,7 @@ macro_rules! event {
);
if $crate::level_enabled!($lvl) {
#[allow(unused_imports)]
use $crate::{callsite, dispatcher, Event, field::{Value, ValueSet}};
use $crate::{callsite, Event, field::{Value, ValueSet}};
use $crate::callsite::Callsite;
let callsite = callsite! {
name: concat!(
Expand Down Expand Up @@ -1860,7 +1860,7 @@ macro_rules! is_enabled {
true
} else {
let meta = $callsite.metadata();
$crate::dispatcher::get_default(|current| current.enabled(meta))
$crate::is_enabled(meta)
}
}};
}
Expand Down