Skip to content

Commit

Permalink
Fix suppression of all console logs when trace_tracy is enabled
Browse files Browse the repository at this point in the history
Bevy was failing to print events from `info!()` and friends to the console if
the `trace_tracy` feature was enabled.

The problem was this per-layer filter that was added in bevyengine#4320 to suppress a
noisy per-frame event (which Tracy requires in order to properly close out a
frame):

- The problem event's target was `"bevy_render::renderer"`, not `"tracy"`.
    - So, the filter wasn't specifically targeting the noisy event.
- Without a default, `tracing_subscriber::filter::Targets` will remove
  _everything_ that doesn't match an explicit target rule.
    - So, the filter _was_ silencing the noisy event, along with everything else.

This commit changes that filter to do what was probably intended in bevyengine#4320:
suppress any events more verbose than `ERROR` from `bevy_render::renderer`, but
allow anything else that already made it through the top-level filter_layer.
  • Loading branch information
nfagerlund committed Dec 14, 2022
1 parent 5718a7e commit 062fb85
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/bevy_log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,14 @@ impl Plugin for LogPlugin {
let tracy_layer = tracing_tracy::TracyLayer::new();

let fmt_layer = tracing_subscriber::fmt::Layer::default();

// bevy_render::renderer logs a `tracy.frame_mark` event every frame
// at Level::INFO. Formatted logs should omit it.
#[cfg(feature = "tracing-tracy")]
let fmt_layer = fmt_layer.with_filter(
tracing_subscriber::filter::Targets::new().with_target("tracy", Level::ERROR),
tracing_subscriber::filter::Targets::new()
.with_target("bevy_render::renderer", Level::ERROR)
.with_default(Level::TRACE),
);

let subscriber = subscriber.with(fmt_layer);
Expand Down

0 comments on commit 062fb85

Please sign in to comment.