recover gracefully from syslog failures

master
Antoine Beaupré 2013-09-07 18:25:46 -04:00
parent cca084b8ad
commit 2869b65bcb
1 changed files with 8 additions and 1 deletions

View File

@ -728,6 +728,7 @@ sub debug ($) {
} }
my $log_open=0; my $log_open=0;
my $log_failed=0;
sub log_message ($$) { sub log_message ($$) {
my $type=shift; my $type=shift;
@ -738,9 +739,15 @@ sub log_message ($$) {
Sys::Syslog::openlog('ikiwiki', '', 'user'); Sys::Syslog::openlog('ikiwiki', '', 'user');
$log_open=1; $log_open=1;
} }
return eval { eval {
Sys::Syslog::syslog($type, "[$config{wikiname}] %s", join(" ", @_)); Sys::Syslog::syslog($type, "[$config{wikiname}] %s", join(" ", @_));
}; };
if ($@) {
print STDERR "failed to syslog: $@" unless $log_failed;
$log_failed=1;
print STDERR "@_\n";
}
return $@;
} }
elsif (! $config{cgi}) { elsif (! $config{cgi}) {
return print "@_\n"; return print "@_\n";