From 82d29fa05845b83daf376580729cfb48ce0ff303 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 19 Dec 2019 23:01:16 -0800 Subject: [PATCH] Battleship/Connect4: put logging behind debug flag, disabled by default --- Plugins/Battleship.pm | 7 +++++-- Plugins/Connect4.pm | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Plugins/Battleship.pm b/Plugins/Battleship.pm index 17410cd0..5e5e7013 100644 --- a/Plugins/Battleship.pm +++ b/Plugins/Battleship.pm @@ -39,6 +39,7 @@ sub initialize { $self->{pbot}->{event_dispatcher}->register_handler('irc.kick', sub { $self->on_kick(@_) }); $self->{channel} = '##battleship'; + $self->{debug} = 0; $self->create_states; } @@ -269,7 +270,9 @@ sub battleship_cmd { } when ('bomb') { - $self->{pbot}->{logger}->log("Battleship: bomb state: $self->{current_state}\n" . Dumper $self->{state_data}); + if ($self->{debug}) { + $self->{pbot}->{logger}->log("Battleship: bomb state: $self->{current_state}\n" . Dumper $self->{state_data}); + } if ($self->{current_state} ne 'playermove' and $self->{current_state} ne 'checkplayer') { return "$nick: It's not time to do that now."; @@ -483,7 +486,7 @@ sub run_one_state { } # dump new state data for logging/debugging - if ($state_data->{newstate}) { + if ($self->{debug} and $state_data->{newstate}) { $self->{pbot}->{logger}->log("Battleship: New state: $self->{current_state}\n" . Dumper $state_data); } diff --git a/Plugins/Connect4.pm b/Plugins/Connect4.pm index a7dfc9b9..a822db14 100644 --- a/Plugins/Connect4.pm +++ b/Plugins/Connect4.pm @@ -39,6 +39,7 @@ sub initialize { $self->{pbot}->{event_dispatcher}->register_handler('irc.quit', sub { $self->on_departure(@_) }); $self->{pbot}->{event_dispatcher}->register_handler('irc.kick', sub { $self->on_kick(@_) }); + $self->{debug} = 0; $self->{channel} = '##connect4'; $self->create_states; } @@ -317,7 +318,9 @@ sub connect4_cmd { } when ('play') { - $self->{pbot}->{logger}->log("Connect4: play state: $self->{current_state}\n" . Dumper $self->{state_data}); + if ($self->{debug}) { + $self->{pbot}->{logger}->log("Connect4: play state: $self->{current_state}\n" . Dumper $self->{state_data}); + } if ($self->{current_state} ne 'playermove') { return "$nick: It's not time to do that now."; @@ -478,7 +481,7 @@ sub run_one_state { } # dump new state data for logging/debugging - if ($state_data->{newstate}) { + if ($self->{debug} and $state_data->{newstate}) { $self->{pbot}->{logger}->log("Connect4: New state: $self->{current_state}\n" . Dumper $state_data); }