Skip to content

Commit

Permalink
update tracing-subscriber to 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Nov 11, 2021
1 parent 9012be6 commit 3ab3691
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tracing-tracy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ harness = false

[dependencies]
tracing-core = { version = "0.1", default-features = false, features = ["std"] }
tracing-subscriber = { version = "0.2", default-features = false, features = ["fmt", "registry"] }
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "registry"] }
tracy-client = { path = "../tracy-client", version = "0.12.1", default-features = false }

[dev-dependencies]
Expand Down
20 changes: 10 additions & 10 deletions tracing-tracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,27 +135,27 @@ where
S: Subscriber + for<'a> registry::LookupSpan<'a>,
F: for<'writer> FormatFields<'writer> + 'static,
{
fn new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) {
fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) {
if let Some(span) = ctx.span(id) {
let mut extensions = span.extensions_mut();
if extensions.get_mut::<FormattedFields<F>>().is_none() {
let mut buf = String::with_capacity(64);
if self.fmt.format_fields(&mut buf, attrs).is_ok() {
extensions.insert(FormattedFields::<F>::new(buf));
let mut fields = FormattedFields::<F>::new(String::with_capacity(64));
if self.fmt.format_fields(fields.as_writer(), attrs).is_ok() {
extensions.insert(fields);
}
}
}
}

fn on_record(&self, id: &Id, values: &Record<'_>, ctx: Context<'_, S>) {
if let Some(span) = ctx.span(id) {
let mut exts = span.extensions_mut();
if let Some(FormattedFields { fields, .. }) = exts.get_mut::<FormattedFields<F>>() {
let mut extensions = span.extensions_mut();
if let Some(fields) = extensions.get_mut::<FormattedFields<F>>() {
let _ = self.fmt.add_fields(fields, values);
} else {
let mut buf = String::with_capacity(64);
if self.fmt.format_fields(&mut buf, values).is_ok() {
exts.insert(FormattedFields::<F>::new(buf));
let mut fields = FormattedFields::<F>::new(String::with_capacity(64));
if self.fmt.format_fields(fields.as_writer(), values).is_ok() {
extensions.insert(fields);
}
}
}
Expand All @@ -181,7 +181,7 @@ where
Span::new(
self.truncate_to_length(
&name,
&file,
file,
"",
"span information is too long and was truncated",
),
Expand Down

0 comments on commit 3ab3691

Please sign in to comment.