Skip to content

Commit

Permalink
subscriber: if error occurs when formatting event, print to stderr
Browse files Browse the repository at this point in the history
This patch adds a single `eprintln` line to let the user know that we
were unable to format a specific event. We are not emitting an actual
tracing Event, to avoid the risk of a cycle (the new Event could
trigger the same formatting error again).

Resolves tokio-rs#1965.
  • Loading branch information
bryangarza committed Apr 29, 2022
1 parent 45c0a10 commit 2eadea5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tracing-subscriber/src/fmt/fmt_layer.rs
Expand Up @@ -896,6 +896,8 @@ where
{
let mut writer = self.make_writer.make_writer_for(event.metadata());
let _ = io::Write::write_all(&mut writer, buf.as_bytes());
} else {
eprintln!("[tracing-subscriber] Unable to format the following event: {:?}", event);
}

buf.clear();
Expand Down

0 comments on commit 2eadea5

Please sign in to comment.