Correct error handling for log_factoid() failure to open file

This commit is contained in:
Pragmatic Software 2015-12-14 14:30:44 -08:00
parent 20a8c30d4c
commit 167d8c2143
1 changed files with 2 additions and 4 deletions

View File

@ -107,12 +107,10 @@ sub log_factoid {
$channel = 'global' if $channel eq '.*';
my $path = $self->{pbot}->{registry}->get_value('general', 'data_dir') . '/factlog';
open my $fh, ">> $path/$trigger.$channel";
if (not $fh) {
open my $fh, ">> $path/$trigger.$channel" or do {
$self->{pbot}->{logger}->log("Failed to open factlog for $channel/$trigger: $!\n");
return;
}
};
my $now = gettimeofday;
print $fh "$now $hostmask $msg\n";