3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-09 04:48:43 +02:00

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

View File

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