From 4c83cc4b4aebfa24daf3b5ae1ba76cc85b868f30 Mon Sep 17 00:00:00 2001 From: Martin Barksten Date: Tue, 20 Sep 2016 19:02:02 +0200 Subject: [PATCH] Sort out some logging problems --- log4rs.toml | 12 +----------- src/main.rs | 2 +- src/messages.rs | 2 +- src/snake.rs | 12 ++++++------ src/structs.rs | 2 -- 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/log4rs.toml b/log4rs.toml index 25cf060..28b7679 100644 --- a/log4rs.toml +++ b/log4rs.toml @@ -1,5 +1,4 @@ [appenders.console] -level = "info" kind = "console" [appenders.console.encoder] @@ -8,25 +7,16 @@ pattern = "{d(%+)(local)} [{t}] {h({l})} {M}:{m}{n}" [appenders.client] kind = "file" path = "log/client.log" -pattern = "{d} [{t}] {l} {M}:{m}{n}" -level = "debug" [appenders.snake] kind = "file" path = "log/snake.log" -pattern = "{d} [{t}] {l} {M}:{m}{n}" -level = "debug" [root] level = "info" appenders = [ "console" ] -[logger.client] +[loggers.client] level = "debug" appenders = [ "client" ] additive = false - -[logger.snake] -level = "debug" -appenders = [ "snake", "console" ] -additive = false diff --git a/src/main.rs b/src/main.rs index 0653f39..1176dc8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -111,7 +111,7 @@ fn route_msg(client: &mut Client, str_msg: &String) -> Result<(), ClientError> { info!(target: LOG_TARGET, "Watch game at {}", msg.url); }, Inbound::UnrecognizedMessage => { - + error!(target: LOG_TARGET, "Received unrecognized message {:?}", str_msg); } }; diff --git a/src/messages.rs b/src/messages.rs index 83e1eba..ac44984 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -17,7 +17,7 @@ pub const PLAYER_REGISTERED: &'static str = pub const INVALID_PLAYER_NAME: &'static str = "se.cygni.snake.api.exception.InvalidPlayerName"; pub const HEART_BEAT_RESPONSE: &'static str = - "se.cygni.snake.api.request.HeartBeatResponse"; + "se.cygni.snake.api.response.HeartBeatResponse"; pub const GAME_LINK_EVENT: &'static str = "se.cygni.snake.api.event.GameLinkEvent"; diff --git a/src/snake.rs b/src/snake.rs index 8682346..bf02a42 100644 --- a/src/snake.rs +++ b/src/snake.rs @@ -17,14 +17,14 @@ impl Snake { } pub fn get_next_move(&self, msg: &MapUpdate) -> Direction { - info!(target: LOG_TARGET, "Game map updated, tick: {}", msg.gameTick); + debug!(target: LOG_TARGET, "Game map updated, tick: {}", msg.gameTick); let ref map = msg.map; let player_id = &msg.receivingPlayerId; let snake = map.get_snake_by_id(player_id).unwrap(); - info!(target: LOG_TARGET, "Food can be found at {:?}", translate_positions(&map.foodPositions, map.width)); - info!(target: LOG_TARGET, "My snake positions are {:?}", translate_positions(&snake.positions, map.width)); + debug!(target: LOG_TARGET, "Food can be found at {:?}", translate_positions(&map.foodPositions, map.width)); + debug!(target: LOG_TARGET, "My snake positions are {:?}", translate_positions(&snake.positions, map.width)); let direction = if map.can_snake_move_in_direction(snake, Direction::Down) { Direction::Down @@ -44,15 +44,15 @@ impl Snake { } pub fn on_game_ended(&self, msg: &GameEnded) { - info!(target: LOG_TARGET, "Game ended, the winner is: {:?}", msg.playerWinnerId); + debug!(target: LOG_TARGET, "Game ended, the winner is: {:?}", msg.playerWinnerId); } pub fn on_tournament_ended(&self, msg: &TournamentEnded) { - info!(target: LOG_TARGET, "Game ended, the winner is: {:?}", msg.playerWinnerId); + debug!(target: LOG_TARGET, "Game ended, the winner is: {:?}", msg.playerWinnerId); } pub fn on_snake_dead(&self, msg: &SnakeDead) { - info!(target: LOG_TARGET, "The snake died, reason was: {:?}", msg.deathReason); + debug!(target: LOG_TARGET, "The snake died, reason was: {:?}", msg.deathReason); } pub fn on_game_starting(&self, _: &GameStarting) { diff --git a/src/structs.rs b/src/structs.rs index 20d5e74..6e2e8f5 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -142,8 +142,6 @@ pub struct TournamentEnded { #[derive(Serialize, Deserialize, Debug)] pub struct Map { - #[serde(rename="type")] - pub type_: String, pub width: i32, pub height: i32, pub worldTick: u32,