recover gracefully from syslog failures
authorAntoine Beaupré <anarcat@koumbit.org>
Sat, 7 Sep 2013 22:25:46 +0000 (18:25 -0400)
committerAntoine Beaupré <anarcat@koumbit.org>
Fri, 29 Nov 2013 06:09:03 +0000 (01:09 -0500)
IkiWiki.pm

index 87ddb1b5643dc279a5a5ea037b9c7ce398d69ba2..2c0b1153c906c7a3fb33d0d575cfca1d87787946 100644 (file)
@@ -728,6 +728,7 @@ sub debug ($) {
 }
 
 my $log_open=0;
 }
 
 my $log_open=0;
+my $log_failed=0;
 sub log_message ($$) {
        my $type=shift;
 
 sub log_message ($$) {
        my $type=shift;
 
@@ -738,9 +739,15 @@ sub log_message ($$) {
                        Sys::Syslog::openlog('ikiwiki', '', 'user');
                        $log_open=1;
                }
                        Sys::Syslog::openlog('ikiwiki', '', 'user');
                        $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}) {
                return print "@_\n";
        }
        elsif (! $config{cgi}) {
                return print "@_\n";