From: Stefan Schantl Date: Wed, 25 Nov 2015 14:29:04 +0000 (+0100) Subject: Redirect the "die" messages to the logger. X-Git-Tag: 2.0~61 X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fguardian.git;a=commitdiff_plain;h=0815025a6f67ed2540767ac35865f1eb119ee628 Redirect the "die" messages to the logger. 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 --- diff --git a/guardian b/guardian index ba8e99c..da9665c 100644 --- 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 = ();