mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 22:30:03 +00:00
Improve derbugg logging (#1738)
* Improve derbugg logging Make it more readable Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix excessive logging Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --------- Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
a2d2c5d85c
commit
4687726c66
10 changed files with 54 additions and 15 deletions
|
@ -212,7 +212,7 @@ impl Download<'_> {
|
||||||
///
|
///
|
||||||
/// NOTE that this API does not support gnu extension sparse file unlike
|
/// NOTE that this API does not support gnu extension sparse file unlike
|
||||||
/// [`Download::and_extract`].
|
/// [`Download::and_extract`].
|
||||||
#[instrument(skip(visitor))]
|
#[instrument(skip(self, visitor))]
|
||||||
pub async fn and_visit_tar(
|
pub async fn and_visit_tar(
|
||||||
self,
|
self,
|
||||||
fmt: TarBasedFmt,
|
fmt: TarBasedFmt,
|
||||||
|
@ -239,7 +239,10 @@ impl Download<'_> {
|
||||||
/// Download a file from the provided URL and extract it to the provided path.
|
/// Download a file from the provided URL and extract it to the provided path.
|
||||||
///
|
///
|
||||||
/// NOTE that this will only extract directory and regular files.
|
/// NOTE that this will only extract directory and regular files.
|
||||||
#[instrument(skip(path))]
|
#[instrument(
|
||||||
|
skip(self, path),
|
||||||
|
fields(path = format_args!("{}", path.as_ref().display()))
|
||||||
|
)]
|
||||||
pub async fn and_extract(
|
pub async fn and_extract(
|
||||||
self,
|
self,
|
||||||
fmt: PkgFmt,
|
fmt: PkgFmt,
|
||||||
|
@ -277,7 +280,7 @@ impl Download<'_> {
|
||||||
inner(self, fmt, path.as_ref()).await
|
inner(self, fmt, path.as_ref()).await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument]
|
#[instrument(skip(self))]
|
||||||
pub async fn into_bytes(self) -> Result<Bytes, DownloadError> {
|
pub async fn into_bytes(self) -> Result<Bytes, DownloadError> {
|
||||||
let bytes = self.content.into_response().await?.bytes().await?;
|
let bytes = self.content.into_response().await?.bytes().await?;
|
||||||
if let Some(verifier) = self.data_verifier {
|
if let Some(verifier) = self.data_verifier {
|
||||||
|
|
|
@ -165,7 +165,12 @@ 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]
|
#[instrument(
|
||||||
|
skip(self, url),
|
||||||
|
fields(
|
||||||
|
url = format_args!("{url}"),
|
||||||
|
),
|
||||||
|
)]
|
||||||
async fn do_send_request(
|
async fn do_send_request(
|
||||||
&self,
|
&self,
|
||||||
request: Request,
|
request: Request,
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl Resolve for TrustDnsResolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "trace")]
|
#[instrument]
|
||||||
fn new_resolver() -> Result<TokioAsyncResolver, BoxError> {
|
fn new_resolver() -> Result<TokioAsyncResolver, BoxError> {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ fn new_resolver() -> Result<TokioAsyncResolver, BoxError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[instrument(level = "trace")]
|
#[instrument]
|
||||||
fn get_adapter() -> Result<ipconfig::Adapter, BoxError> {
|
fn get_adapter() -> Result<ipconfig::Adapter, BoxError> {
|
||||||
debug!("Retrieving local IP address");
|
debug!("Retrieving local IP address");
|
||||||
let local_ip =
|
let local_ip =
|
||||||
|
|
|
@ -180,7 +180,7 @@ impl Data {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug")]
|
#[instrument(skip(client))]
|
||||||
async fn get_repo_info(&self, client: &GhApiClient) -> Result<Option<&RepoInfo>, FetchError> {
|
async fn get_repo_info(&self, client: &GhApiClient) -> Result<Option<&RepoInfo>, FetchError> {
|
||||||
self.repo_info
|
self.repo_info
|
||||||
.get_or_try_init(move || {
|
.get_or_try_init(move || {
|
||||||
|
|
|
@ -12,7 +12,7 @@ use std::{
|
||||||
use binstalk_downloader::{download::Download, remote};
|
use binstalk_downloader::{download::Download, remote};
|
||||||
use compact_str::{format_compact, CompactString, ToCompactString};
|
use compact_str::{format_compact, CompactString, ToCompactString};
|
||||||
use tokio::sync::OnceCell;
|
use tokio::sync::OnceCell;
|
||||||
use tracing::instrument;
|
use tracing::{instrument, Level};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
@ -224,7 +224,7 @@ impl GhApiClient {
|
||||||
.map_err(|err| err.context("Restful API"))
|
.map_err(|err| err.context("Restful API"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug", skip(self), ret)]
|
#[instrument(skip(self), ret(level = Level::DEBUG))]
|
||||||
pub async fn get_repo_info(&self, repo: &GhRepo) -> Result<Option<RepoInfo>, GhApiError> {
|
pub async fn get_repo_info(&self, repo: &GhRepo) -> Result<Option<RepoInfo>, GhApiError> {
|
||||||
match self
|
match self
|
||||||
.do_fetch(
|
.do_fetch(
|
||||||
|
@ -248,7 +248,7 @@ impl GhApiClient {
|
||||||
/// Return `Ok(Some(api_artifact_url))` if exists.
|
/// Return `Ok(Some(api_artifact_url))` if exists.
|
||||||
///
|
///
|
||||||
/// The returned future is guaranteed to be pointer size.
|
/// The returned future is guaranteed to be pointer size.
|
||||||
#[instrument(level = "debug", skip(self), ret)]
|
#[instrument(skip(self), ret(level = Level::DEBUG))]
|
||||||
pub async fn has_release_artifact(
|
pub async fn has_release_artifact(
|
||||||
&self,
|
&self,
|
||||||
GhReleaseArtifact {
|
GhReleaseArtifact {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::future::Future;
|
use std::{fmt, future::Future};
|
||||||
|
|
||||||
use compact_str::CompactString;
|
use compact_str::CompactString;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
@ -20,6 +20,16 @@ pub struct RepoInfo {
|
||||||
private: bool,
|
private: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for RepoInfo {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"RepoInfo {{ owner: {}, name: {}, is_private: {} }}",
|
||||||
|
self.owner.login, self.name, self.private
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl RepoInfo {
|
impl RepoInfo {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub(crate) fn new(GhRepo { owner, repo }: GhRepo, private: bool) -> Self {
|
pub(crate) fn new(GhRepo { owner, repo }: GhRepo, private: bool) -> Self {
|
||||||
|
|
|
@ -55,7 +55,12 @@ impl DataVerifier for Sha256Digest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument]
|
#[instrument(
|
||||||
|
skip(client, crate_url),
|
||||||
|
fields(
|
||||||
|
crate_url = format_args!("{crate_url}"),
|
||||||
|
),
|
||||||
|
)]
|
||||||
pub(super) async fn parse_manifest(
|
pub(super) async fn parse_manifest(
|
||||||
client: Client,
|
client: Client,
|
||||||
crate_name: &str,
|
crate_name: &str,
|
||||||
|
|
|
@ -105,7 +105,12 @@ 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]
|
#[instrument(
|
||||||
|
skip(client),
|
||||||
|
fields(
|
||||||
|
version_req = format_args!("{version_req}"),
|
||||||
|
)
|
||||||
|
)]
|
||||||
pub async fn fetch_crate_cratesio_api(
|
pub async fn fetch_crate_cratesio_api(
|
||||||
client: Client,
|
client: Client,
|
||||||
name: &str,
|
name: &str,
|
||||||
|
|
|
@ -97,7 +97,12 @@ impl GitRegistry {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument]
|
#[instrument(
|
||||||
|
skip(self, client, version_req),
|
||||||
|
fields(
|
||||||
|
version_req = format_args!("{version_req}"),
|
||||||
|
),
|
||||||
|
)]
|
||||||
pub async fn fetch_crate_matched(
|
pub async fn fetch_crate_matched(
|
||||||
&self,
|
&self,
|
||||||
client: Client,
|
client: Client,
|
||||||
|
|
|
@ -78,7 +78,13 @@ impl SparseRegistry {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument]
|
#[instrument(
|
||||||
|
skip(self, client, version_req),
|
||||||
|
fields(
|
||||||
|
registry_url = format_args!("{}", self.url),
|
||||||
|
version_req = format_args!("{version_req}"),
|
||||||
|
)
|
||||||
|
)]
|
||||||
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