From 84c23d3be428bb2b2dc1d572e664b228b790dd3f Mon Sep 17 00:00:00 2001 From: Niko Tyni Date: Tue, 24 Oct 2006 19:04:12 +0000 Subject: handle a dead syslogd (Debian bug #395056) --- lib/Smokeping.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/Smokeping.pm') diff --git a/lib/Smokeping.pm b/lib/Smokeping.pm index 04e320d..3f76a7e 100644 --- a/lib/Smokeping.pm +++ b/lib/Smokeping.pm @@ -2705,12 +2705,22 @@ sub daemonize_me ($) { $syslog_priority = $pri if defined $pri; print "Note: logging to syslog as $syslog_facility/$syslog_priority.\n"; openlog(basename($0), 'pid', $syslog_facility); + eval { + syslog($syslog_priority, 'Starting syslog logging'); + }; + die("can't log to syslog: $@") if $@; } sub do_syslog ($){ my $str = shift; $str =~ s,%,%%,g; - syslog("$syslog_facility|$syslog_priority", $str); + eval { + syslog("$syslog_facility|$syslog_priority", $str); + }; + # syslogd is probably dead if that failed + # this message is most probably lost too, if we have daemonized + # let's try anyway, it shouldn't hurt + print STDERR qq(Can't log "$str" to syslog: $@) if $@; } sub do_cgilog ($){ -- cgit v1.2.3-24-g4f1b