Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace use of log with tracing #527

Merged
merged 10 commits into from
Nov 13, 2022
36 changes: 14 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ binstalk = { path = "../binstalk", version = "0.4.1" }
clap = { version = "4.0.22", features = ["derive"] }
crates_io_api = { version = "0.8.1", default-features = false }
dirs = "4.0.0"
log = "0.4.17"
log = { version = "0.4.17", features = ["std"] }
miette = "5.4.1"
mimalloc = { version = "0.1.31", default-features = false, optional = true }
once_cell = "1.16.0"
Expand Down
3 changes: 2 additions & 1 deletion crates/bin/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ use binstalk::{
resolve::{CrateName, Resolution, VersionReqExt},
},
};
use log::{debug, error, info, warn, LevelFilter};
use log::LevelFilter;
use miette::{miette, Result, WrapErr};
use tokio::task::block_in_place;
use tracing::{debug, error, info, warn};

use crate::{
args::{Args, Strategy},
Expand Down
2 changes: 1 addition & 1 deletion crates/bin/src/install_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
};

use binstalk::home::cargo_home;
use log::debug;
use tracing::debug;

pub fn get_cargo_roots_path(cargo_roots: Option<PathBuf>) -> Option<PathBuf> {
if let Some(p) = cargo_roots {
Expand Down
2 changes: 1 addition & 1 deletion crates/bin/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Instant;

use binstalk::helpers::jobserver_client::LazyJobserverClient;
use log::debug;
use tracing::debug;

use cargo_binstall::{
args,
Expand Down
2 changes: 1 addition & 1 deletion crates/binstalk-downloader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ flate2 = { version = "1.0.24", default-features = false }
futures-util = { version = "0.3.25", default-features = false, features = ["std"] }
generic-array = "0.14.6"
httpdate = "1.0.2"
log = { version = "0.4.17", features = ["std"] }
reqwest = { version = "0.11.12", features = ["stream", "gzip", "brotli", "deflate"], default-features = false }
scopeguard = "1.1.0"
# Use a fork here since we need PAX support, but the upstream
Expand All @@ -30,6 +29,7 @@ tempfile = "3.3.0"
thiserror = "1.0.37"
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread", "sync", "time"], default-features = false }
tower = { version = "0.4.13", features = ["limit", "util"] }
tracing = "0.1.37"
trust-dns-resolver = { version = "0.21.2", optional = true, default-features = false, features = ["dnssec-ring"] }
url = "2.3.1"

Expand Down
4 changes: 3 additions & 1 deletion crates/binstalk-downloader/src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::{fmt::Debug, future::Future, io, marker::PhantomData, path::Path, pin::

use binstalk_manifests::cargo_toml_binstall::{PkgFmtDecomposed, TarBasedFmt};
use digest::{Digest, FixedOutput, HashMarker, Output, OutputSizeUser, Update};
use log::debug;
use thiserror::Error as ThisError;
use tracing::{debug, instrument};

pub use binstalk_manifests::cargo_toml_binstall::PkgFmt;
pub use tar::Entries;
Expand Down Expand Up @@ -92,6 +92,7 @@ impl Download {
///
/// `cancellation_future` can be used to cancel the extraction and return
/// [`DownloadError::UserAbort`] error.
#[instrument(skip(visitor, cancellation_future))]
pub async fn and_visit_tar<V: TarEntriesVisitor + Debug + Send + 'static>(
self,
fmt: TarBasedFmt,
Expand All @@ -114,6 +115,7 @@ impl Download {
///
/// `cancellation_future` can be used to cancel the extraction and return
/// [`DownloadError::UserAbort`] error.
#[instrument(skip(path, cancellation_future))]
pub async fn and_extract(
self,
fmt: PkgFmt,
Expand Down
2 changes: 1 addition & 1 deletion crates/binstalk-downloader/src/download/async_extracter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use std::{

use bytes::Bytes;
use futures_util::stream::Stream;
use log::debug;
use scopeguard::{guard, ScopeGuard};
use tar::Entries;
use tempfile::tempfile;
use tokio::task::block_in_place;
use tracing::debug;

use super::{
extracter::*, stream_readable::StreamReadable, CancellationFuture, DownloadError, TarBasedFmt,
Expand Down
2 changes: 1 addition & 1 deletion crates/binstalk-downloader/src/download/extracter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::{

use bzip2::bufread::BzDecoder;
use flate2::bufread::GzDecoder;
use log::debug;
use tar::Archive;
use tracing::debug;
use xz2::bufread::XzDecoder;
use zip::read::ZipArchive;
use zstd::stream::Decoder as ZstdDecoder;
Expand Down
2 changes: 1 addition & 1 deletion crates/binstalk-downloader/src/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ use std::{
use bytes::Bytes;
use futures_util::stream::{Stream, StreamExt};
use httpdate::parse_http_date;
use log::{debug, info};
use reqwest::{
header::{HeaderMap, RETRY_AFTER},
Request, Response, StatusCode,
};
use thiserror::Error as ThisError;
use tokio::{sync::Mutex, time::sleep};
use tower::{limit::rate::RateLimit, Service, ServiceBuilder, ServiceExt};
use tracing::{debug, info};

pub use reqwest::{tls, Error as ReqwestError, Method};
pub use url::Url;
Expand Down
5 changes: 1 addition & 4 deletions crates/binstalk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ futures-util = { version = "0.3.25", default-features = false, features = ["std"
home = "0.5.4"
itertools = "0.10.5"
jobslot = { version = "0.2.6", features = ["tokio"] }
log = { version = "0.4.17", features = ["std"] }
miette = "5.4.1"
normalize-path = { version = "0.2.0", path = "../normalize-path" }
once_cell = "1.16.0"
Expand All @@ -33,12 +32,10 @@ thiserror = "1.0.37"
tinytemplate = "1.2.1"
# parking_lot for `tokio::sync::OnceCell::const_new`
tokio = { version = "1.21.2", features = ["rt", "process", "sync", "signal", "parking_lot"], default-features = false }
tracing = "0.1.37"
url = { version = "2.3.1", features = ["serde"] }
xz2 = "0.1.7"

[dev-dependencies]
env_logger = "0.9.3"

[features]
default = ["static", "rustls"]

Expand Down
2 changes: 1 addition & 1 deletion crates/binstalk/src/bins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use std::{

use cargo_toml::Product;
use compact_str::CompactString;
use log::debug;
use normalize_path::NormalizePath;
use serde::Serialize;
use tinytemplate::TinyTemplate;
use tracing::debug;

use crate::{
errors::BinstallError,
Expand Down
2 changes: 1 addition & 1 deletion crates/binstalk/src/drivers/crates_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::path::PathBuf;

use cargo_toml::Manifest;
use crates_io_api::AsyncClient;
use log::debug;
use semver::VersionReq;
use tracing::debug;

use crate::{
errors::BinstallError,
Expand Down
2 changes: 1 addition & 1 deletion crates/binstalk/src/drivers/crates_io/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::{
};

use cargo_toml::Manifest;
use log::debug;
use normalize_path::NormalizePath;
use tracing::debug;

use super::vfs::Vfs;
use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/binstalk/src/drivers/version.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use log::debug;
use semver::VersionReq;
use tracing::debug;

use crate::errors::BinstallError;

Expand Down
1 change: 0 additions & 1 deletion crates/binstalk/src/fetchers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::{path::Path, sync::Arc};

use compact_str::CompactString;
pub use gh_crate_meta::*;
pub use log::debug;
pub use quickinstall::*;

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/binstalk/src/fetchers/gh_crate_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use std::{path::Path, sync::Arc};

use compact_str::{CompactString, ToCompactString};
use futures_util::stream::{FuturesUnordered, StreamExt};
use log::{debug, warn};
use once_cell::sync::OnceCell;
use serde::Serialize;
use strum::IntoEnumIterator;
use tinytemplate::TinyTemplate;
use tracing::{debug, warn};
use url::Url;

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/binstalk/src/fetchers/quickinstall.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{path::Path, sync::Arc};

use compact_str::CompactString;
use log::debug;
use tokio::task::JoinHandle;
use tracing::debug;
use url::Url;

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/binstalk/src/fs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{fs, io, path::Path};

use log::debug;
use tempfile::NamedTempFile;
use tracing::debug;

/// Atomically install a file.
///
Expand Down
3 changes: 2 additions & 1 deletion crates/binstalk/src/ops/install.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{borrow::Cow, env, ffi::OsStr, sync::Arc};

use compact_str::CompactString;
use log::{debug, error, info};
use tokio::{process::Command, task::block_in_place};
use tracing::{debug, error, info, instrument};

use super::{resolve::Resolution, Options};
use crate::{
Expand All @@ -12,6 +12,7 @@ use crate::{
manifests::crate_info::{CrateInfo, CrateSource},
};

#[instrument(skip_all)]
pub async fn install(
resolution: Resolution,
opts: Arc<Options>,
Expand Down
3 changes: 2 additions & 1 deletion crates/binstalk/src/ops/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use std::{
use cargo_toml::{Manifest, Package, Product};
use compact_str::{CompactString, ToCompactString};
use itertools::Itertools;
use log::{debug, info, warn};
use semver::{Version, VersionReq};
use tokio::task::block_in_place;
use tracing::{debug, info, instrument, warn};

use super::Options;
use crate::{
Expand Down Expand Up @@ -89,6 +89,7 @@ impl Resolution {
}
}

#[instrument(skip_all)]
pub async fn resolve(
opts: Arc<Options>,
crate_name: CrateName,
Expand Down
2 changes: 0 additions & 2 deletions crates/binstalk/tests/parse-meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ use cargo_toml::Product;

#[test]
fn parse_meta() {
let _ = env_logger::builder().is_test(true).try_init();

let mut manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
manifest_dir.push_str("/tests/parse-meta.Cargo.toml");

Expand Down