Pass logger object to the mainsettings hash for a usage
authorStefan Schantl <stefan.schantl@ipfire.org>
Sun, 6 Dec 2015 09:38:46 +0000 (10:38 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sun, 6 Dec 2015 09:38:46 +0000 (10:38 +0100)
inside of the modules.

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

index f480c11..9245f90 100644 (file)
--- a/guardian
+++ b/guardian
@@ -73,6 +73,10 @@ my %mainsettings = &Guardian::Config::UseConfig($cmdargs{"config"});
 my $logger = Guardian::Logger->New(%mainsettings);
 $logger->Log("debug", "Logger successfully initialized...");
 
+# Add the logger object to the mainsettings for passing
+# it to the modules.
+$mainsettings{Logger} = $logger;
+
 # Redirect perls "die" messages to the logger before exiting.
 $SIG{__DIE__} = sub { $logger->Log("err", "@_"); };
 
@@ -339,6 +343,12 @@ sub Reload () {
        # Re-read configuration file.
        %mainsettings = &Guardian::Config::UseConfig($cmdargs{"config"});
 
+       # Update Logger settings.
+       $logger = Guardian::Logger->Update(%mainsettings);
+
+       # Update logger object in mainsettings hash.
+       $mainsettings{Logger} = $logger;
+
        # Re-generate hash of monitored files.
        %monitored_files = &Guardian::Base::GenerateMonitoredFiles(\%mainsettings, \%monitored_files);