]> git.ipfire.org Git - people/stevee/guardian.git/commitdiff
Redirect the "die" messages to the logger.
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 25 Nov 2015 14:29:04 +0000 (15:29 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Wed, 25 Nov 2015 14:29:04 +0000 (15:29 +0100)
When an error occurs and perl dies, the provided error messages now
will be handled/logged by the "Logger" module.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
guardian

index ba8e99cf52400c8c92cebdbdc2a1441cf53cd95c..da9665cc8e8fb0d561655722707a66f72e3e510d 100644 (file)
--- a/guardian
+++ b/guardian
@@ -73,6 +73,9 @@ my %mainsettings = &Guardian::Config::UseConfig($cmdargs{"config"});
 my $logger = Guardian::Logger->New(%mainsettings);
 $logger->Log("debug", "Logger successfully initialized...");
 
+# Redirect perls "die" messages to the logger before exiting.
+$SIG{__DIE__} = sub { $logger->Log("err", "@_"); };
+
 # Shared hash between the main process and all threads. It will store all
 # monitored files and their current file position.
 my %monitored_files :shared = ();