fix: log level issue
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
parent
8a07bf163c
commit
74fe2a3b4a
2 changed files with 26 additions and 6 deletions
27
src/main.rs
27
src/main.rs
|
@ -3,8 +3,8 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
use std::{env, io, net::SocketAddr};
|
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
use std::{env, io, net::SocketAddr};
|
||||||
|
|
||||||
use dns_lookup::lookup_host;
|
use dns_lookup::lookup_host;
|
||||||
use futures::future::join_all;
|
use futures::future::join_all;
|
||||||
|
@ -32,8 +32,6 @@ async fn main() -> io::Result<()> {
|
||||||
let host_name: String;
|
let host_name: String;
|
||||||
let cache_url: String;
|
let cache_url: String;
|
||||||
|
|
||||||
pretty_env_logger::init();
|
|
||||||
|
|
||||||
let matches = cli::build_cli().get_matches();
|
let matches = cli::build_cli().get_matches();
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -52,6 +50,11 @@ async fn main() -> io::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//pretty_env_logger::init();
|
||||||
|
pretty_env_logger::formatted_timed_builder()
|
||||||
|
.parse_env("RUST_LOG")
|
||||||
|
.init();
|
||||||
|
|
||||||
if let Some(name) = matches.get_one::<String>("name") {
|
if let Some(name) = matches.get_one::<String>("name") {
|
||||||
host_name = name.to_owned();
|
host_name = name.to_owned();
|
||||||
} else {
|
} else {
|
||||||
|
@ -80,6 +83,11 @@ async fn main() -> io::Result<()> {
|
||||||
|
|
||||||
let get_requisites_duration = initial_time.elapsed().as_secs();
|
let get_requisites_duration = initial_time.elapsed().as_secs();
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"Found Nix Requisites in {} seconds",
|
||||||
|
get_requisites_duration
|
||||||
|
);
|
||||||
|
|
||||||
let network_time = Instant::now();
|
let network_time = Instant::now();
|
||||||
|
|
||||||
let lines = binding
|
let lines = binding
|
||||||
|
@ -107,10 +115,17 @@ async fn main() -> io::Result<()> {
|
||||||
.map(|result| result.unwrap())
|
.map(|result| result.unwrap())
|
||||||
.sum();
|
.sum();
|
||||||
|
|
||||||
println!("Found Nix Requisites in {} seconds", get_requisites_duration);
|
println!(
|
||||||
println!("Checked {count} packages in {} seconds", network_time.elapsed().as_secs());
|
"Checked {count} packages in {} seconds",
|
||||||
|
network_time.elapsed().as_secs()
|
||||||
|
);
|
||||||
println!("");
|
println!("");
|
||||||
println!("Found {:#?}/{} ({:.2}%) in cache", sum, count, (sum as f64 /count as f64) * 100.);
|
println!(
|
||||||
|
"Found {:#?}/{} ({:.2}%) in cache",
|
||||||
|
sum,
|
||||||
|
count,
|
||||||
|
(sum as f64 / count as f64) * 100.
|
||||||
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@ use async_recursion::async_recursion;
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
|
use log::{debug, error, info, trace, warn};
|
||||||
|
|
||||||
const MAX_SLIDE: u64 = 1000;
|
const MAX_SLIDE: u64 = 1000;
|
||||||
|
|
||||||
#[async_recursion]
|
#[async_recursion]
|
||||||
|
@ -21,6 +24,8 @@ pub async fn nar_exists(client: Client, domain: &str, hash: &str, slide: u64) ->
|
||||||
//
|
//
|
||||||
// Writng an actual sliding window seems kinda hard,
|
// Writng an actual sliding window seems kinda hard,
|
||||||
// so we do this instead.
|
// so we do this instead.
|
||||||
|
trace!("rate limited! {slide}");
|
||||||
|
println!("");
|
||||||
sleep(Duration::from_millis(slide)).await;
|
sleep(Duration::from_millis(slide)).await;
|
||||||
nar_exists(client, domain, hash, std::cmp::min(slide * 2, MAX_SLIDE)).await
|
nar_exists(client, domain, hash, std::cmp::min(slide * 2, MAX_SLIDE)).await
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue