mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15: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
|
@ -39,17 +39,28 @@ pub fn main() {
|
|||
desktop::cli::main()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub fn main() {
|
||||
println!(
|
||||
"Cannot start /ports/servoshell/ on Android. \
|
||||
Use /support/android/apk/ + `libservoshell.so` instead"
|
||||
);
|
||||
}
|
||||
pub fn init_tracing() {
|
||||
#[cfg(feature = "tracing")]
|
||||
{
|
||||
let subscriber = tracing_subscriber::registry();
|
||||
|
||||
#[cfg(target_env = "ohos")]
|
||||
pub fn main() {
|
||||
println!("You shouldn't start /ports/servoshell/ on OpenHarmony.");
|
||||
#[cfg(feature = "tracing-perfetto")]
|
||||
let subscriber = {
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
// Set up a PerfettoLayer for performance tracing.
|
||||
// The servo.pftrace file can be uploaded to https://ui.perfetto.dev for analysis.
|
||||
let file = std::fs::File::create("servo.pftrace").unwrap();
|
||||
let perfetto_layer = tracing_perfetto::PerfettoLayer::new(std::sync::Mutex::new(file));
|
||||
subscriber.with(perfetto_layer)
|
||||
};
|
||||
|
||||
// Same as SubscriberInitExt::init, but avoids initialising the tracing-log compat layer,
|
||||
// since it would break Servo’s FromScriptLogger and FromCompositorLogger.
|
||||
// <https://docs.rs/tracing-subscriber/0.3.18/tracing_subscriber/util/trait.SubscriberInitExt.html#method.init>
|
||||
// <https://docs.rs/tracing/0.1.40/tracing/#consuming-log-records>
|
||||
tracing::subscriber::set_global_default(subscriber)
|
||||
.expect("Failed to set tracing subscriber");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn servo_version() -> String {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue