mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 22:30:03 +00:00
feat: Add more logging to binstalk-{downloader, registry}
(#1340)
for debugging purposes. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
3c5641610a
commit
3e67e3624a
5 changed files with 13 additions and 6 deletions
|
@ -13,7 +13,7 @@ use reqwest::{
|
||||||
Request,
|
Request,
|
||||||
};
|
};
|
||||||
use thiserror::Error as ThisError;
|
use thiserror::Error as ThisError;
|
||||||
use tracing::{debug, info};
|
use tracing::{debug, info, instrument};
|
||||||
|
|
||||||
pub use reqwest::{header, Error as ReqwestError, Method, StatusCode};
|
pub use reqwest::{header, Error as ReqwestError, Method, StatusCode};
|
||||||
pub use url::Url;
|
pub use url::Url;
|
||||||
|
@ -155,6 +155,7 @@ impl Client {
|
||||||
///
|
///
|
||||||
/// Return `Ok(ControlFlow::Break(response))` when succeeds and no need
|
/// Return `Ok(ControlFlow::Break(response))` when succeeds and no need
|
||||||
/// to retry.
|
/// to retry.
|
||||||
|
#[instrument]
|
||||||
async fn do_send_request(
|
async fn do_send_request(
|
||||||
&self,
|
&self,
|
||||||
request: Request,
|
request: Request,
|
||||||
|
@ -177,7 +178,7 @@ impl Client {
|
||||||
let status = response.status();
|
let status = response.status();
|
||||||
|
|
||||||
let add_delay_and_continue = |response: reqwest::Response, duration| {
|
let add_delay_and_continue = |response: reqwest::Response, duration| {
|
||||||
info!("Receiver status code {status}, will wait for {duration:#?} and retry");
|
info!("Received status code {status}, will wait for {duration:#?} and retry");
|
||||||
|
|
||||||
self.0
|
self.0
|
||||||
.service
|
.service
|
||||||
|
@ -237,6 +238,8 @@ impl Client {
|
||||||
request: Request,
|
request: Request,
|
||||||
error_for_status: bool,
|
error_for_status: bool,
|
||||||
) -> Result<reqwest::Response, Error> {
|
) -> Result<reqwest::Response, Error> {
|
||||||
|
debug!("Downloading from: '{}'", request.url());
|
||||||
|
|
||||||
self.send_request_inner(&request)
|
self.send_request_inner(&request)
|
||||||
.await
|
.await
|
||||||
.and_then(|response| {
|
.and_then(|response| {
|
||||||
|
@ -313,8 +316,6 @@ impl Client {
|
||||||
&self,
|
&self,
|
||||||
url: Url,
|
url: Url,
|
||||||
) -> Result<impl Stream<Item = Result<Bytes, Error>>, Error> {
|
) -> Result<impl Stream<Item = Result<Bytes, Error>>, Error> {
|
||||||
debug!("Downloading from: '{url}'");
|
|
||||||
|
|
||||||
Ok(self.get(url).send(true).await?.bytes_stream())
|
Ok(self.get(url).send(true).await?.bytes_stream())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ use semver::{Version, VersionReq};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Error as JsonError;
|
use serde_json::Error as JsonError;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use tracing::debug;
|
use tracing::{debug, instrument};
|
||||||
|
|
||||||
use crate::{visitor::ManifestVisitor, RegistryError};
|
use crate::{visitor::ManifestVisitor, RegistryError};
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ impl DataVerifier for Sha256Digest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument]
|
||||||
pub(super) async fn parse_manifest(
|
pub(super) async fn parse_manifest(
|
||||||
client: Client,
|
client: Client,
|
||||||
crate_name: &str,
|
crate_name: &str,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use cargo_toml_workspace::cargo_toml::Manifest;
|
||||||
use compact_str::{CompactString, ToCompactString};
|
use compact_str::{CompactString, ToCompactString};
|
||||||
use semver::{Comparator, Op as ComparatorOp, Version as SemVersion, VersionReq};
|
use semver::{Comparator, Op as ComparatorOp, Version as SemVersion, VersionReq};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use tracing::debug;
|
use tracing::{debug, instrument};
|
||||||
|
|
||||||
use crate::{parse_manifest, MatchedVersion, RegistryError};
|
use crate::{parse_manifest, MatchedVersion, RegistryError};
|
||||||
|
|
||||||
|
@ -105,6 +105,7 @@ async fn fetch_crate_cratesio_version_matched(
|
||||||
|
|
||||||
/// Find the crate by name, get its latest stable version matches `version_req`,
|
/// Find the crate by name, get its latest stable version matches `version_req`,
|
||||||
/// retrieve its Cargo.toml and infer all its bins.
|
/// retrieve its Cargo.toml and infer all its bins.
|
||||||
|
#[instrument]
|
||||||
pub async fn fetch_crate_cratesio_api(
|
pub async fn fetch_crate_cratesio_api(
|
||||||
client: Client,
|
client: Client,
|
||||||
name: &str,
|
name: &str,
|
||||||
|
|
|
@ -10,6 +10,7 @@ use serde_json::{from_slice as json_from_slice, Deserializer as JsonDeserializer
|
||||||
use simple_git::{GitCancellationToken, GitUrl, Repository};
|
use simple_git::{GitCancellationToken, GitUrl, Repository};
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
use tokio::task::spawn_blocking;
|
use tokio::task::spawn_blocking;
|
||||||
|
use tracing::instrument;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -96,6 +97,7 @@ impl GitRegistry {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument]
|
||||||
pub async fn fetch_crate_matched(
|
pub async fn fetch_crate_matched(
|
||||||
&self,
|
&self,
|
||||||
client: Client,
|
client: Client,
|
||||||
|
|
|
@ -5,6 +5,7 @@ use compact_str::CompactString;
|
||||||
use semver::VersionReq;
|
use semver::VersionReq;
|
||||||
use serde_json::Deserializer as JsonDeserializer;
|
use serde_json::Deserializer as JsonDeserializer;
|
||||||
use tokio::sync::OnceCell;
|
use tokio::sync::OnceCell;
|
||||||
|
use tracing::instrument;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -77,6 +78,7 @@ impl SparseRegistry {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument]
|
||||||
pub async fn fetch_crate_matched(
|
pub async fn fetch_crate_matched(
|
||||||
&self,
|
&self,
|
||||||
client: Client,
|
client: Client,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue