Skip to content

Commit

Permalink
feat: change log level for UDP server stdoutput messages
Browse files Browse the repository at this point in the history
The Cargo.toml file has these options:

```
[profile.release]
debug = 1
opt-level = 3
lto = "fat"
strip = true
```

I think that hides "debug" messages in release builds. SO when I use the
docker image on Azure container or my local machine I do not see those
messages. I think for the time being we can show them.

On the other hand, there is a "debug" message that should be an "error"
message:

```
Err(_) => {
    error!("could not write response to bytes.");
}
```

That message shoudl be shown on production too.
  • Loading branch information
josecelano committed Dec 10, 2022
1 parent 415a252 commit 8415879
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/udp/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::net::SocketAddr;
use std::sync::Arc;

use aquatic_udp_protocol::Response;
use log::{debug, info};
use log::{debug, error, info};
use tokio::net::UdpSocket;

use crate::tracker;
Expand Down Expand Up @@ -45,8 +45,8 @@ impl Udp {
Ok((valid_bytes, remote_addr)) = socket.recv_from(&mut data) => {
let payload = data[..valid_bytes].to_vec();

debug!("Received {} bytes from {}", payload.len(), remote_addr);
debug!("{:?}", payload);
info!("Received {} bytes from {}", payload.len(), remote_addr);
info!("{:?}", payload);

let response = handle_packet(remote_addr, payload, tracker).await;
Udp::send_response(socket, remote_addr, response).await;
Expand All @@ -56,7 +56,7 @@ impl Udp {
}

async fn send_response(socket: Arc<UdpSocket>, remote_addr: SocketAddr, response: Response) {
debug!("sending response to: {:?}", &remote_addr);
info!("sending response to: {:?}", &remote_addr);

let buffer = vec![0u8; MAX_PACKET_SIZE];
let mut cursor = Cursor::new(buffer);
Expand All @@ -71,7 +71,7 @@ impl Udp {
Udp::send_packet(socket, &remote_addr, &inner[..position]).await;
}
Err(_) => {
debug!("could not write response to bytes.");
error!("could not write response to bytes.");
}
}
}
Expand Down

0 comments on commit 8415879

Please sign in to comment.