Sort out some logging problems

This commit is contained in:
Martin Barksten
2016-09-20 19:02:02 +02:00
parent 5b65df2596
commit 4c83cc4b4a
5 changed files with 9 additions and 21 deletions

View File

@ -1,5 +1,4 @@
[appenders.console] [appenders.console]
level = "info"
kind = "console" kind = "console"
[appenders.console.encoder] [appenders.console.encoder]
@ -8,25 +7,16 @@ pattern = "{d(%+)(local)} [{t}] {h({l})} {M}:{m}{n}"
[appenders.client] [appenders.client]
kind = "file" kind = "file"
path = "log/client.log" path = "log/client.log"
pattern = "{d} [{t}] {l} {M}:{m}{n}"
level = "debug"
[appenders.snake] [appenders.snake]
kind = "file" kind = "file"
path = "log/snake.log" path = "log/snake.log"
pattern = "{d} [{t}] {l} {M}:{m}{n}"
level = "debug"
[root] [root]
level = "info" level = "info"
appenders = [ "console" ] appenders = [ "console" ]
[logger.client] [loggers.client]
level = "debug" level = "debug"
appenders = [ "client" ] appenders = [ "client" ]
additive = false additive = false
[logger.snake]
level = "debug"
appenders = [ "snake", "console" ]
additive = false

View File

@ -111,7 +111,7 @@ fn route_msg(client: &mut Client, str_msg: &String) -> Result<(), ClientError> {
info!(target: LOG_TARGET, "Watch game at {}", msg.url); info!(target: LOG_TARGET, "Watch game at {}", msg.url);
}, },
Inbound::UnrecognizedMessage => { Inbound::UnrecognizedMessage => {
error!(target: LOG_TARGET, "Received unrecognized message {:?}", str_msg);
} }
}; };

View File

@ -17,7 +17,7 @@ pub const PLAYER_REGISTERED: &'static str =
pub const INVALID_PLAYER_NAME: &'static str = pub const INVALID_PLAYER_NAME: &'static str =
"se.cygni.snake.api.exception.InvalidPlayerName"; "se.cygni.snake.api.exception.InvalidPlayerName";
pub const HEART_BEAT_RESPONSE: &'static str = 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 = pub const GAME_LINK_EVENT: &'static str =
"se.cygni.snake.api.event.GameLinkEvent"; "se.cygni.snake.api.event.GameLinkEvent";

View File

@ -17,14 +17,14 @@ impl Snake {
} }
pub fn get_next_move(&self, msg: &MapUpdate) -> Direction { 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 ref map = msg.map;
let player_id = &msg.receivingPlayerId; let player_id = &msg.receivingPlayerId;
let snake = map.get_snake_by_id(player_id).unwrap(); 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)); debug!(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, "My snake positions are {:?}", translate_positions(&snake.positions, map.width));
let direction = if map.can_snake_move_in_direction(snake, Direction::Down) { let direction = if map.can_snake_move_in_direction(snake, Direction::Down) {
Direction::Down Direction::Down
@ -44,15 +44,15 @@ impl Snake {
} }
pub fn on_game_ended(&self, msg: &GameEnded) { 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) { 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) { 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) { pub fn on_game_starting(&self, _: &GameStarting) {

View File

@ -142,8 +142,6 @@ pub struct TournamentEnded {
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct Map { pub struct Map {
#[serde(rename="type")]
pub type_: String,
pub width: i32, pub width: i32,
pub height: i32, pub height: i32,
pub worldTick: u32, pub worldTick: u32,