diff --git a/exec/logconfig.c b/exec/logconfig.c index b37622ec..350d8a94 100644 --- a/exec/logconfig.c +++ b/exec/logconfig.c @@ -52,6 +52,7 @@ static const char *main_logfile; #include "util.h" #include "logconfig.h" +#include "totemknet.h" static char error_string_response[512]; @@ -623,6 +624,9 @@ static int corosync_main_config_read_logging ( #endif logsys_config_apply(); + + /* Reconfigure knet logging */ + totemknet_configure_log_level(); return 0; parse_error: diff --git a/exec/logsys.c b/exec/logsys.c index 88da45e1..30a4ee60 100644 --- a/exec/logsys.c +++ b/exec/logsys.c @@ -803,6 +803,23 @@ void logsys_config_apply(void) } } +extern int logsys_config_debug_get ( + const char *subsys) +{ + int debug_level = logsys_loggers[0].debug; + int i; + + if (subsys != NULL) { + pthread_mutex_lock (&logsys_config_mutex); + i = _logsys_config_subsys_get_unlocked (subsys); + if (i >= 0) { + debug_level = logsys_loggers[i].debug; + } + pthread_mutex_unlock (&logsys_config_mutex); + } + return debug_level; +} + int logsys_config_debug_set ( const char *subsys, unsigned int debug) diff --git a/exec/totemknet.c b/exec/totemknet.c index 0782c018..6ad09b8e 100644 --- a/exec/totemknet.c +++ b/exec/totemknet.c @@ -885,6 +885,36 @@ static void knet_set_access_list_config(struct totemknet_instance *instance) #endif } +void totemknet_configure_log_level() +{ + int logsys_log_mode; + int knet_log_mode = KNET_LOG_INFO; + uint8_t s; + + if (!global_instance || !global_instance->knet_handle) { + return; + } + + /* Reconfigure logging level */ + logsys_log_mode = logsys_config_debug_get("KNET"); + + switch (logsys_log_mode) { + case LOGSYS_DEBUG_OFF: + knet_log_mode = KNET_LOG_INFO; + break; + case LOGSYS_DEBUG_ON: + knet_log_mode = KNET_LOG_DEBUG; + break; + case LOGSYS_DEBUG_TRACE: + knet_log_mode = KNET_LOG_DEBUG; + break; + } + log_printf (LOGSYS_LEVEL_DEBUG, "totemknet setting log level %s", knet_log_get_loglevel_name(knet_log_mode)); + for (s = 0; sknet_handle, s, knet_log_mode); + } +} + /* NOTE: this relies on the fact that totem_reload_notify() is called first */ static void totemknet_refresh_config( @@ -958,6 +988,7 @@ static void totemknet_refresh_config( } } + /* Log levels get reconfigured from logconfig.c as that happens last in the reload */ LEAVE(); } @@ -1200,6 +1231,9 @@ int totemknet_initialize ( } global_instance = instance; + /* Setup knet logging level */ + totemknet_configure_log_level(); + /* Get an fd into knet */ instance->knet_fd = 0; res = knet_handle_add_datafd(instance->knet_handle, &instance->knet_fd, &channel); diff --git a/exec/totemknet.h b/exec/totemknet.h index 30068747..67c0ba6e 100644 --- a/exec/totemknet.h +++ b/exec/totemknet.h @@ -154,4 +154,6 @@ extern int totemknet_crypto_reconfigure_phase ( extern void totemknet_stats_clear ( void *knet_context); +extern void totemknet_configure_log_level (void); + #endif /* TOTEMKNET_H_DEFINED */ diff --git a/include/corosync/logsys.h b/include/corosync/logsys.h index 6f768242..325b24be 100644 --- a/include/corosync/logsys.h +++ b/include/corosync/logsys.h @@ -196,6 +196,15 @@ extern int logsys_config_debug_set ( const char *subsys, unsigned int value); +/** + * @brief Return the debug flag for this subsys + * + * @param subsys + * @return LOGSYS_DEBUG_OFF | LOGSYS_DEBUG_ON | LOGSYS_DEBUG_TRACE + */ +extern int logsys_config_debug_get ( + const char *subsys); + /* * External API - helpers * diff --git a/vqsim/vqmain.c b/vqsim/vqmain.c index e42ce9fd..8e5f0e3f 100644 --- a/vqsim/vqmain.c +++ b/vqsim/vqmain.c @@ -26,6 +26,7 @@ extern int coroparse_configparse (icmap_map_t config_map, const char **error_string); extern int corosync_log_config_read (const char **error_string); static int stdin_read_fn(int32_t fd, int32_t revents, void *data); +void totemknet_configure_log_level(void); /* 'Keep the compiler happy' time */ const char *corosync_get_config_file(void); @@ -270,6 +271,11 @@ static int vq_parent_read_fn(int32_t fd, int32_t revents, void *data) return 0; } +/* Dummy routine to keep the linker happy */ +void totemknet_configure_log_level(void) +{ + +} static int read_corosync_conf(void) {