From 87767cbec25720850e1f50b814e5052d3cd4f549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Tue, 3 May 2022 15:35:04 +0000 Subject: [PATCH] can specify chrome tracing file (#4618) # Objective - I want to have the trace file at a predictable path ## Solution - Adds an environment variable that is used as the path when it's set --- .github/workflows/ci.yml | 2 +- crates/bevy_log/src/lib.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61cc9a7a0e22d9..4d4c465fef8342 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -283,7 +283,7 @@ jobs: for example in .github/example-run/*.ron; do example_name=`basename $example .ron` echo "running $example_name - "`date` - time CI_TESTING_CONFIG=$example xvfb-run cargo run --example $example_name --no-default-features --features "bevy_dynamic_plugin,bevy_gilrs,bevy_gltf,bevy_winit,render,png,hdr,x11,bevy_ci_testing,trace,trace_chrome,bevy_audio,vorbis" + time TRACE_CHROME=trace-$example_name.json CI_TESTING_CONFIG=$example xvfb-run cargo run --example $example_name --no-default-features --features "bevy_dynamic_plugin,bevy_gilrs,bevy_gltf,bevy_winit,render,png,hdr,x11,bevy_ci_testing,trace,trace_chrome,bevy_audio,vorbis" sleep 10 done zip traces.zip trace*.json diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs index 0dd24a477d07b9..0259aafd714575 100644 --- a/crates/bevy_log/src/lib.rs +++ b/crates/bevy_log/src/lib.rs @@ -137,7 +137,11 @@ impl Plugin for LogPlugin { { #[cfg(feature = "tracing-chrome")] let chrome_layer = { - let (chrome_layer, guard) = tracing_chrome::ChromeLayerBuilder::new() + let mut layer = tracing_chrome::ChromeLayerBuilder::new(); + if let Ok(path) = std::env::var("TRACE_CHROME") { + layer = layer.file(path); + } + let (chrome_layer, guard) = layer .name_fn(Box::new(|event_or_span| match event_or_span { tracing_chrome::EventOrSpan::Event(event) => event.metadata().name().into(), tracing_chrome::EventOrSpan::Span(span) => {