Skip to content

Commit

Permalink
usage for log
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSammyM committed Dec 7, 2023
1 parent 74f4bf9 commit ff30418
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/src/game/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use rand::seq::SliceRandom;
use rand::thread_rng;

use crate::lobby::LobbyPlayer;
use crate::log;
use crate::packet::{ToClientPacket, GameOverReason};
use chat::{ChatMessage, ChatGroup};
use player::PlayerReference;
Expand Down Expand Up @@ -71,7 +72,10 @@ impl Game {
player.sender.clone(),
match roles.get(player_index){
Some(role) => *role,
None => RoleOutline::Any.get_random_role(&settings.excluded_roles, &roles).expect("Any should have open roles"),
None => {
log!(error "Game::new"; "Failed to generate role. rolelist wasnt big enough for number of players");
RoleOutline::Any.get_random_role(&settings.excluded_roles, &roles).expect("Any should have open roles")
},
}
);
players.push(new_player);
Expand Down
8 changes: 8 additions & 0 deletions server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ pub mod log {
#[macro_export]
/// Log a statement to the console.
/// When logging using this macro, a timestamp and possibly a marker is added to the message.
///
/// # Examples
/// ```
/// use crate::log;
/// log!(error "Error location"; "Error message");
/// log!(error "Game::new"; "Failed to generate role. rolelist wasnt big enough for number of players");
/// log!(info "Listener"; "{}: {}", &connection.get_address().to_string(), message);
/// ```
macro_rules! log {
// Each case in this macro definition is for a different log marker.
// None
Expand Down

1 comment on commit ff30418

@vercel
Copy link

@vercel vercel bot commented on ff30418 Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

mafia-game – ./

mafia-game-git-00x-main-itssammym.vercel.app
mafia-game-itssammym.vercel.app
mafia-game.vercel.app

Please sign in to comment.