mirror of https://github.com/rust-lang/cargo
fix(cli): Skip tracing-chrome for platforms without 64bit atomics
This commit is contained in:
parent
00b9882b9c
commit
307ad0c496
|
@ -199,13 +199,15 @@ time.workspace = true
|
|||
toml.workspace = true
|
||||
toml_edit.workspace = true
|
||||
tracing.workspace = true
|
||||
tracing-chrome.workspace = true
|
||||
tracing-subscriber.workspace = true
|
||||
unicase.workspace = true
|
||||
unicode-width.workspace = true
|
||||
url.workspace = true
|
||||
walkdir.workspace = true
|
||||
|
||||
[target.'cfg(target_has_atomic = "64")'.dependencies]
|
||||
tracing-chrome.workspace = true
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
cargo-credential-libsecret.workspace = true
|
||||
|
||||
|
|
|
@ -41,9 +41,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
fn setup_logger() -> Option<tracing_chrome::FlushGuard> {
|
||||
#![allow(clippy::disallowed_methods)]
|
||||
|
||||
fn setup_logger() -> Option<ChromeFlushGuard> {
|
||||
use tracing_subscriber::prelude::*;
|
||||
|
||||
let env = tracing_subscriber::EnvFilter::from_env("CARGO_LOG");
|
||||
|
@ -53,17 +51,7 @@ fn setup_logger() -> Option<tracing_chrome::FlushGuard> {
|
|||
.with_writer(std::io::stderr)
|
||||
.with_filter(env);
|
||||
|
||||
let (profile_layer, profile_guard) =
|
||||
if env_to_bool(std::env::var_os("CARGO_LOG_PROFILE").as_deref()) {
|
||||
let capture_args =
|
||||
env_to_bool(std::env::var_os("CARGO_LOG_PROFILE_CAPTURE_ARGS").as_deref());
|
||||
let (layer, guard) = tracing_chrome::ChromeLayerBuilder::new()
|
||||
.include_args(capture_args)
|
||||
.build();
|
||||
(Some(layer), Some(guard))
|
||||
} else {
|
||||
(None, None)
|
||||
};
|
||||
let (profile_layer, profile_guard) = chrome_layer();
|
||||
|
||||
let registry = tracing_subscriber::registry()
|
||||
.with(fmt_layer)
|
||||
|
@ -73,6 +61,44 @@ fn setup_logger() -> Option<tracing_chrome::FlushGuard> {
|
|||
profile_guard
|
||||
}
|
||||
|
||||
#[cfg(target_has_atomic = "64")]
|
||||
type ChromeFlushGuard = tracing_chrome::FlushGuard;
|
||||
#[cfg(target_has_atomic = "64")]
|
||||
fn chrome_layer<S>() -> (
|
||||
Option<tracing_chrome::ChromeLayer<S>>,
|
||||
Option<ChromeFlushGuard>,
|
||||
)
|
||||
where
|
||||
S: tracing::Subscriber
|
||||
+ for<'span> tracing_subscriber::registry::LookupSpan<'span>
|
||||
+ Send
|
||||
+ Sync,
|
||||
{
|
||||
#![allow(clippy::disallowed_methods)]
|
||||
|
||||
if env_to_bool(std::env::var_os("CARGO_LOG_PROFILE").as_deref()) {
|
||||
let capture_args =
|
||||
env_to_bool(std::env::var_os("CARGO_LOG_PROFILE_CAPTURE_ARGS").as_deref());
|
||||
let (layer, guard) = tracing_chrome::ChromeLayerBuilder::new()
|
||||
.include_args(capture_args)
|
||||
.build();
|
||||
(Some(layer), Some(guard))
|
||||
} else {
|
||||
(None, None)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_has_atomic = "64"))]
|
||||
type ChromeFlushGuard = ();
|
||||
#[cfg(not(target_has_atomic = "64"))]
|
||||
fn chrome_layer() -> (
|
||||
Option<tracing_subscriber::layer::Identity>,
|
||||
Option<ChromeFlushGuard>,
|
||||
) {
|
||||
(None, None)
|
||||
}
|
||||
|
||||
#[cfg(target_has_atomic = "64")]
|
||||
fn env_to_bool(os: Option<&OsStr>) -> bool {
|
||||
match os.and_then(|os| os.to_str()) {
|
||||
Some("1") | Some("true") => true,
|
||||
|
|
Loading…
Reference in New Issue