mirror of
https://github.com/servo/servo.git
synced 2025-08-12 00:45:33 +01:00
Make tracing available on all platforms, with or without perfetto (#33301)
* Make tracing available on all platforms Signed-off-by: Delan Azabani <dazabani@igalia.com> * Gate perfetto support behind its own feature Signed-off-by: Delan Azabani <dazabani@igalia.com> --------- Signed-off-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
parent
891562be8e
commit
c0ced7a524
8 changed files with 33 additions and 79 deletions
|
@ -8,42 +8,13 @@ use getopts::Options;
|
|||
use log::error;
|
||||
use servo::config::opts::{self, ArgumentParsingResult};
|
||||
use servo::servo_config::pref;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing::subscriber::set_global_default;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing_perfetto::PerfettoLayer;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
use crate::desktop::app::App;
|
||||
use crate::panic_hook;
|
||||
|
||||
pub fn main() {
|
||||
crate::crash_handler::install();
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
{
|
||||
let file = std::fs::File::create("servo.pftrace").unwrap();
|
||||
let perfetto_layer = PerfettoLayer::new(std::sync::Mutex::new(file));
|
||||
|
||||
// Set up a custom tracing subscriber and PerfettoLayer for performance tracing.
|
||||
// The servo.pftrace file can be uploaded to https://ui.perfetto.dev for analysis.
|
||||
let env_filter_layer = EnvFilter::from_default_env();
|
||||
let subscriber = tracing_subscriber::registry()
|
||||
.with(env_filter_layer)
|
||||
.with(perfetto_layer);
|
||||
|
||||
// Set the subscriber as the global default for tracing. This means it will be used
|
||||
// throughout the entire program unless a thread-local subscriber is set.
|
||||
// Can only be set once; subsequent attempts will fail.
|
||||
// <https://docs.rs/tracing/0.1.40/src/tracing/subscriber.rs.html#30>
|
||||
set_global_default(subscriber).expect("Failed to set global default subscriber");
|
||||
}
|
||||
|
||||
crate::init_tracing();
|
||||
crate::resources::init();
|
||||
|
||||
// Parse the command line options and store them globally
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue