better logging

Use callbacks to report progress, indicatif for progress bars, no direct logs but progress messages
This commit is contained in:
2025-11-27 19:34:46 +01:00
parent a4d2441b0a
commit 311304666f
5 changed files with 158 additions and 57 deletions

View File

@@ -1,10 +1,11 @@
use flate2::read::GzDecoder;
use std::io::Read;
use std::collections::HashMap;
use serde::Deserialize;
use std::error::Error;
use std::path::Path;
use log::debug;
const BASE_URL_UBUNTU: &str = "http://archive.ubuntu.com/ubuntu";
const BASE_URL_DEBIAN: &str = "http://deb.debian.org/debian";
@@ -185,7 +186,7 @@ pub async fn get(package_name: &str, series: &str, pocket: &str) -> Result<Optio
let mut preferred_vcs = None;
if dist == "ubuntu" {
if let Some(lp_url) = check_launchpad_repo(package_name).await? {
println!("Found Launchpad URL: {}", lp_url);
debug!("Found Launchpad URL: {}", lp_url);
preferred_vcs = Some(lp_url);
}
}
@@ -195,12 +196,12 @@ pub async fn get(package_name: &str, series: &str, pocket: &str) -> Result<Optio
let component = "main"; // TODO: Make configurable or detect
let url = get_sources_url(base_url, series, pocket, component);
println!("Fetching sources from: {}", url);
debug!("Fetching sources from: {}", url);
let response = reqwest::get(&url).await?;
let compressed_data = response.bytes().await?;
println!("Downloaded Sources.gz for {}/{}", dist, series);
debug!("Downloaded Sources.gz for {}/{}", dist, series);
if let Some(stanza) = parse_sources(&compressed_data, package_name)? {
if let Some(vcs) = &stanza.vcs_git {
@@ -217,8 +218,7 @@ pub async fn get(package_name: &str, series: &str, pocket: &str) -> Result<Optio
archive_url: archive_url,
}));
} else {
// println!("Package '{}' not found in {}/{}", package, dist, series);
Ok(None)
Err(format!("Package '{}' not found in {}/{}", package_name, dist, series).into())
}
}