edenapi: optionally print log messages

Summary: Add log messages for debugging using the `tracing` crate, which allows them to be enabled via `env_logger`.

Reviewed By: quark-zju

Differential Revision: D23858076

fbshipit-source-id: a8ef1afac6c9ecbfb5d6d78232aa0d03a2fe2054
This commit is contained in:
Arun Kulshreshtha 2020-09-23 17:17:40 -07:00 committed by Facebook GitHub Bot
parent 613fbc858f
commit a745a145b1
2 changed files with 19 additions and 0 deletions

View File

@ -37,4 +37,5 @@ serde_json = "1.0"
structopt = "0.3.7"
thiserror = "1.0"
tokio = { version = "=0.2.13", features = ["full"] }
tracing = "0.1"
url = "2.1.0"

View File

@ -151,8 +151,12 @@ impl Client {
impl EdenApi for Client {
async fn health(&self) -> Result<ResponseMeta, EdenApiError> {
let url = self.url(paths::HEALTH_CHECK, None)?;
tracing::info!("Sending health check request: {}", &url);
let req = self.configure(Request::get(url))?;
let res = req.send_async().await?;
Ok(ResponseMeta::from(&res))
}
@ -162,6 +166,8 @@ impl EdenApi for Client {
keys: Vec<Key>,
progress: Option<ProgressCallback>,
) -> Result<Fetch<FileEntry>, EdenApiError> {
tracing::info!("Requesting content for {} files", keys.len());
if keys.is_empty() {
return Err(EdenApiError::EmptyRequest);
}
@ -181,6 +187,8 @@ impl EdenApi for Client {
length: Option<u32>,
progress: Option<ProgressCallback>,
) -> Result<Fetch<HistoryEntry>, EdenApiError> {
tracing::info!("Requesting history for {} files", keys.len());
if keys.is_empty() {
return Err(EdenApiError::EmptyRequest);
}
@ -217,6 +225,8 @@ impl EdenApi for Client {
keys: Vec<Key>,
progress: Option<ProgressCallback>,
) -> Result<Fetch<TreeEntry>, EdenApiError> {
tracing::info!("Requesting content for {} files", keys.len());
if keys.is_empty() {
return Err(EdenApiError::EmptyRequest);
}
@ -238,6 +248,12 @@ impl EdenApi for Client {
depth: Option<usize>,
progress: Option<ProgressCallback>,
) -> Result<Fetch<TreeEntry>, EdenApiError> {
tracing::info!(
"Requesting {} complete trees for directory {}",
mfnodes.len(),
&rootdir
);
let url = self.url(paths::COMPLETE_TREES, Some(&repo))?;
let tree_req = CompleteTreeRequest {
rootdir,
@ -260,6 +276,8 @@ impl EdenApi for Client {
hgids: Vec<HgId>,
progress: Option<ProgressCallback>,
) -> Result<Fetch<CommitRevlogData>, EdenApiError> {
tracing::info!("Requesting revlog data for {} commits", hgids.len());
let url = self.url(paths::COMMIT_REVLOG_DATA, Some(&repo))?;
let commit_revlog_data_req = CommitRevlogDataRequest { hgids };