Changed log to tracing

This commit is contained in:
Igor Katson 2023-11-19 12:50:11 +00:00
parent db12bba7a6
commit 48a14823fa
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
26 changed files with 321 additions and 689 deletions

View file

@ -17,7 +17,6 @@ use bencode::ByteString;
use futures::{stream::FuturesUnordered, Stream, StreamExt};
use indexmap::IndexSet;
use librqbit_core::{id20::Id20, peer_id::generate_peer_id};
use log::{debug, info, trace, warn};
use parking_lot::RwLock;
use rand::Rng;
use serde::Serialize;
@ -26,6 +25,7 @@ use tokio::{
sync::mpsc::{channel, unbounded_channel, Sender, UnboundedReceiver, UnboundedSender},
};
use tokio_stream::wrappers::{errors::BroadcastStreamRecvError, BroadcastStream};
use tracing::{debug, info, trace, warn};
#[derive(Debug, Serialize)]
pub struct DhtStats {
@ -449,7 +449,7 @@ async fn run_framer(
Err(_) => break,
}
}
Err(e) => log::debug!("{}: error deserializing incoming message: {}", addr, e),
Err(e) => debug!("{}: error deserializing incoming message: {}", addr, e),
}
}
Err::<(), _>(anyhow::anyhow!(

View file

@ -2,13 +2,11 @@ use std::{str::FromStr, time::Duration};
use anyhow::Context;
use librqbit_dht::{Dht, Id20};
use log::info;
use tokio_stream::StreamExt;
use tracing::info;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
pretty_env_logger::init();
let info_hash = Id20::from_str("64a980abe6e448226bb930ba061592e44c3781a1").unwrap();
let dht = Dht::new().await.context("error initializing DHT")?;
let mut stream = dht.get_peers(info_hash).await?;
@ -42,7 +40,7 @@ async fn main() -> anyhow::Result<()> {
let peer_printer = async {
while let Some(peer) = stream.next().await {
log::info!("peer found: {}", peer)
info!("peer found: {}", peer)
}
Ok(())
};

View file

@ -8,8 +8,8 @@ use std::path::{Path, PathBuf};
use std::time::Duration;
use anyhow::Context;
use log::{debug, error, info, trace, warn};
use tokio::spawn;
use tracing::{debug, error, info, trace, warn};
use crate::dht::{Dht, DhtConfig};
use crate::routing_table::RoutingTable;

View file

@ -4,8 +4,8 @@ use std::{
};
use librqbit_core::id20::Id20;
use log::debug;
use serde::{ser::SerializeMap, Deserialize, Serialize};
use tracing::debug;
#[derive(Debug, Clone, Serialize, Deserialize)]
enum BucketTreeNodeData {