summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index 06f0c05..27051f1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,6 +3,7 @@ use std::net::{SocketAddr, ToSocketAddrs};
use clap::{arg, Parser};
use tokio::net::UdpSocket;
+use tracing::{debug, error};
use crate::Destination::{Address, SockAddr};
@@ -36,6 +37,7 @@ enum Destination<'a> {
#[tokio::main]
async fn main() {
+ tracing_subscriber::fmt::init();
let args = Args::parse();
let key = hex::decode(args.key)
.expect("failed to decode key hex string");
@@ -52,7 +54,7 @@ async fn main() {
loop {
match sock.recv_from(&mut buf).await {
Ok((len, addr)) => {
- eprintln!("recv_from OK, len {}, addr {}", len, addr);
+ debug!("recv_from OK, len {}, addr {}", len, addr);
let mut i = 0;
let n = key.len();
for j in 0..len {
@@ -72,7 +74,7 @@ async fn main() {
Address(addr) => match resolve_addr(&addr) {
Ok(addr) => SockAddr(addr),
Err(why) => {
- eprintln!("Failed to resolve address {}: {}", addr, why);
+ error!("Failed to resolve address {}: {}", addr, why);
Destination::None
}
},
@@ -90,20 +92,20 @@ async fn main() {
};
match target {
None => {
- eprintln!("cannot send_to: destination not determined");
+ error!("cannot send_to: destination not determined");
continue;
}
Some(target) => {
if let Err(why) = sock.send_to(&buf[..len], target).await {
- eprintln!("send_to failed, dest: {}, error: {}", target, why);
+ debug!("send_to failed, dest: {}, error: {}", target, why);
} else {
- eprintln!("send_to OK, len: {}, dest: {}", len, target);
+ debug!("send_to OK, len: {}, dest: {}", len, target);
}
}
}
}
Err(why) => {
- eprintln!("recv_from failed: {}", why);
+ debug!("recv_from failed: {}", why);
}
}
}