From acf7e27d188be9e79c947bdeab4974f97c8c8cfc Mon Sep 17 00:00:00 2001 From: Titouan Rigoudy Date: Fri, 19 Feb 2016 15:04:27 +0100 Subject: [PATCH] Change all println's to rather use the logging framework. --- src/main.rs | 2 +- src/server.rs | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 44ff568..58c4585 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,7 +33,7 @@ fn main() { let host = config::SERVER_HOST; let port = config::SERVER_PORT; let stream = connect(host, port).unwrap(); - println!("Connected to {}:{}", host, port); + info!("Connected to {}:{}", host, port); let mut event_loop = EventLoop::new().unwrap(); diff --git a/src/server.rs b/src/server.rs index fc9afd6..01e877b 100644 --- a/src/server.rs +++ b/src/server.rs @@ -40,7 +40,7 @@ impl ServerConnection { pub fn server_writable(&mut self) { match self.state { State::NotLoggedIn => { - println!("Logging in..."); + info!("Logging in..."); self.state = State::LoggingIn; self.server_interest = EventSet::readable(); let request = ServerRequest::LoginRequest(LoginRequest::new( @@ -79,7 +79,7 @@ impl ServerConnection { self.handle_room_list_response(room_list_response), ServerResponse::UnknownResponse(code, _) => - println!("Unknown packet code {}", code), + warn!("Unknown packet code {}", code), } } @@ -99,18 +99,17 @@ impl ServerConnection { LoginResponse::LoginOk { motd, ip, password_md5_opt } => { self.state = State::LoggedIn; - println!("Login successful!"); - println!("MOTD: \"{}\"", motd); - println!("IP address: {}", ip); + info!("Login successful!"); + info!("MOTD: \"{}\"", motd); + info!("External IP address: {}", ip); match password_md5_opt { Some(password_md5) => { - println!("Password MD5: \"{}\"", password_md5); - println!(concat!( + info!(concat!( "Connected to official server ", "as official client")); }, - None => println!(concat!( + None => info!(concat!( "Connected to official server ", "as unofficial client")), } @@ -118,8 +117,7 @@ impl ServerConnection { LoginResponse::LoginFail { reason } => { self.state = State::NotLoggedIn; - println!("Login failed!"); - println!("Reason: {}", reason); + error!("Login failed: \"{}\"", reason); } } },