Skip to content

Commit a38344c

Browse files
committed
fix(logging): Set default loglevel to INFO
Signed-off-by: rrouviere <ruben.rouviere@etu.umontpellier.fr>
1 parent 698a375 commit a38344c

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

topics/p2p-transfer-protocol/b

53.7 KB
Binary file not shown.

topics/p2p-transfer-protocol/src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ enum Commands {
4040
}
4141

4242
fn main() {
43-
// Initialize logger
44-
env_logger::init();
43+
// Initialize logger to INFO level by default
44+
env_logger::init_from_env(
45+
env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"),
46+
);
4547

4648
let cli = Cli::parse();
4749
// Note: if no command matches, clap automatically provides the help message & exits.
@@ -81,7 +83,7 @@ fn server_mode(bind_addr: &str, file_path: &str) -> io::Result<()> {
8183
.create(true)
8284
.open(file_path)?;
8385

84-
println!(
86+
info!(
8587
"Server listening on {:?}. Saving to {}",
8688
listener, file_path
8789
);

topics/p2p-transfer-protocol/src/server/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ use std::fs::File;
22
use std::io;
33
use std::net::TcpStream;
44

5+
use log::info;
6+
57
use crate::server::connection::handle_connection;
68

79
mod connection;
810
mod events;
911

1012
pub fn run_server(file: &mut File, stream: &mut TcpStream) -> Result<(), io::Error> {
1113
let peer_addr = stream.peer_addr()?;
12-
println!("New connection from {peer_addr}");
14+
info!("New connection from {peer_addr}");
1315

1416
handle_connection(file, stream)
1517
}

0 commit comments

Comments
 (0)