mirror of
https://git.proxmox.com/git/mirror_corosync
synced 2025-10-04 00:31:15 +00:00
log: Configure knet logging to the same as corosync
Before this, all knet messages, including debug, were sent over the pipe from knet to corosync and filtered in corosync. This was obviously a waste, so now we tell knet the logging level we need from it and so only get the messages that the user has requested. Signed-off-by: Christine Caulfield <ccaulfie@redhat.com> Reviewed-by: Jan Friesse <jfriesse@redhat.com>
This commit is contained in:
parent
04362046c4
commit
7b96a937df
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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; s<KNET_MAX_SUBSYSTEMS; s++) {
|
||||
knet_log_set_loglevel(global_instance->knet_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);
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user