custom-logger: Add optional reload method
authorThomas Egerer <thomas.egerer@secunet.com>
Wed, 29 Aug 2018 11:14:59 +0000 (13:14 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 29 Aug 2018 13:55:33 +0000 (15:55 +0200)
The reload of the configuration of the loggers so far only included
the log levels. In order to support the reload of all other options,
a reload function may be implemented.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
src/libcharon/bus/listeners/custom_logger.h
src/libcharon/daemon.c

index a256ad1..4856163 100644 (file)
@@ -49,12 +49,17 @@ struct custom_logger_t {
         * @param group         debug group to set
         * @param level         max level to log (0..4)
         */
-       void (*set_level) (custom_logger_t *this, debug_t group, level_t level);
+       void (*set_level)(custom_logger_t *this, debug_t group, level_t level);
+
+       /**
+        * Reload custom logger configuration.
+        */
+       void (*reload)(custom_logger_t *this);
 
        /**
         * Destroy the custom_logger_t object.
         */
-       void (*destroy) (custom_logger_t *this);
+       void (*destroy)(custom_logger_t *this);
 };
 
 /**
index c02ab28..2029921 100644 (file)
@@ -549,6 +549,10 @@ static void load_custom_logger(private_daemon_t *this,
                                lib->settings->get_int(lib->settings, "%s.customlog.%s.%N", def,
                                                        lib->ns, entry->name, debug_lower_names, group));
        }
+       if (custom_logger->reload)
+       {
+               custom_logger->reload(custom_logger);
+       }
        charon->bus->add_logger(charon->bus, &custom_logger->logger);
 }