From 0815025a6f67ed2540767ac35865f1eb119ee628 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Wed, 25 Nov 2015 15:29:04 +0100 Subject: [PATCH] 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 --- guardian | 3 +++ 1 file changed, 3 insertions(+) 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 = (); -- 2.39.2