Kaynağa Gözat

libqb: logging & trace

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
Angus Salkeld 14 yıl önce
ebeveyn
işleme
37e17e7a94

+ 2 - 2
exec/coroparse.c

@@ -54,6 +54,7 @@
 #include <corosync/lcr/lcr_comp.h>
 #include <corosync/lcr/lcr_comp.h>
 #include <corosync/engine/objdb.h>
 #include <corosync/engine/objdb.h>
 #include <corosync/engine/config.h>
 #include <corosync/engine/config.h>
+#include <qb/qbutil.h>
 #define LOGSYS_UTILS_ONLY 1
 #define LOGSYS_UTILS_ONLY 1
 #include <corosync/engine/logsys.h>
 #include <corosync/engine/logsys.h>
 
 
@@ -363,8 +364,7 @@ static int read_config_file_into_objdb(
 	fp = fopen (filename, "r");
 	fp = fopen (filename, "r");
 	if (fp == NULL) {
 	if (fp == NULL) {
 		char error_str[100];
 		char error_str[100];
-		const char *error_ptr;
-		LOGSYS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
+		const char *error_ptr = qb_strerror_r(errno, error_str, sizeof(error_str));
 		snprintf (error_reason, sizeof(error_string_response),
 		snprintf (error_reason, sizeof(error_string_response),
 			"Can't read file %s reason = (%s)\n",
 			"Can't read file %s reason = (%s)\n",
 			 filename, error_ptr);
 			 filename, error_ptr);

+ 0 - 26
exec/ipc_glue.c

@@ -67,7 +67,6 @@
 LOGSYS_DECLARE_SUBSYS ("MAIN");
 LOGSYS_DECLARE_SUBSYS ("MAIN");
 
 
 static struct corosync_api_v1 *api = NULL;
 static struct corosync_api_v1 *api = NULL;
-static int ipc_subsys_id = -1;
 static int32_t ipc_not_enough_fds_left = 0;
 static int32_t ipc_not_enough_fds_left = 0;
 static int32_t ipc_fc_is_quorate; /* boolean */
 static int32_t ipc_fc_is_quorate; /* boolean */
 static int32_t ipc_fc_totem_queue_level; /* percentage used */
 static int32_t ipc_fc_totem_queue_level; /* percentage used */
@@ -779,22 +778,6 @@ void cs_ipcs_sync_state_changed(int32_t sync_in_process)
 	cs_ipcs_check_for_flow_control();
 	cs_ipcs_check_for_flow_control();
 }
 }
 
 
-static void cs_ipcs_libqb_log_fn(const char *file_name,
-	int32_t file_line,
-	int32_t severity,
-	const char *msg)
-{
-	int32_t level = severity;
-	if (severity > LOG_DEBUG) {
-		level = LOGSYS_LEVEL_DEBUG;
-	}
-
-	_logsys_log_printf (LOGSYS_ENCODE_RECID(level,
-			ipc_subsys_id,
-			LOGSYS_RECID_LOG),
-		__func__, file_name, file_line, "%s", msg);
-}
-
 void cs_ipcs_stats_update(void)
 void cs_ipcs_stats_update(void)
 {
 {
 	int32_t i;
 	int32_t i;
@@ -891,15 +874,6 @@ void cs_ipcs_init(void)
 
 
 	qb_loop_poll_low_fds_event_set(cs_poll_handle_get(), cs_ipcs_low_fds_event);
 	qb_loop_poll_low_fds_event_set(cs_poll_handle_get(), cs_ipcs_low_fds_event);
 
 
-	ipc_subsys_id = _logsys_subsys_create ("IPC");
-	if (ipc_subsys_id < 0) {
-		log_printf (LOGSYS_LEVEL_ERROR,
-			"Could not initialize IPC logging subsystem\n");
-		corosync_exit_error (AIS_DONE_INIT_SERVICES);
-	}
-
-	qb_util_set_log_function (cs_ipcs_libqb_log_fn);
-
 	api->quorum_register_callback (cs_ipcs_fc_quorum_changed, NULL);
 	api->quorum_register_callback (cs_ipcs_fc_quorum_changed, NULL);
 	totempg_queue_level_register_callback (cs_ipcs_totem_queue_level_changed);
 	totempg_queue_level_register_callback (cs_ipcs_totem_queue_level_changed);
 
 

Dosya farkı çok büyük olduğundan ihmal edildi
+ 115 - 742
exec/logsys.c


+ 45 - 23
exec/main.c

@@ -96,6 +96,7 @@
 #include <semaphore.h>
 #include <semaphore.h>
 
 
 #include <qb/qbdefs.h>
 #include <qb/qbdefs.h>
+#include <qb/qblog.h>
 #include <qb/qbloop.h>
 #include <qb/qbloop.h>
 #include <qb/qbutil.h>
 #include <qb/qbutil.h>
 #include <qb/qbipcs.h>
 #include <qb/qbipcs.h>
@@ -131,14 +132,9 @@
 #endif
 #endif
 
 
 LOGSYS_DECLARE_SYSTEM ("corosync",
 LOGSYS_DECLARE_SYSTEM ("corosync",
-	LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_THREADED | LOGSYS_MODE_FORK,
-	0,
-	NULL,
-	LOG_INFO,
+	LOGSYS_MODE_OUTPUT_STDERR,
 	LOG_DAEMON,
 	LOG_DAEMON,
-	LOG_INFO,
-	NULL,
-	IPC_LOGSYS_SIZE);
+	LOG_INFO);
 
 
 LOGSYS_DECLARE_SUBSYS ("MAIN");
 LOGSYS_DECLARE_SUBSYS ("MAIN");
 
 
@@ -220,7 +216,7 @@ void corosync_shutdown_request (void)
 static int32_t sig_diag_handler (int num, void *data)
 static int32_t sig_diag_handler (int num, void *data)
 {
 {
 	corosync_state_dump ();
 	corosync_state_dump ();
-	logsys_log_rec_store (LOCALSTATEDIR "/lib/corosync/fdata");
+	qb_log_blackbox_write_to_file(LOCALSTATEDIR "/lib/corosync/fdata");
 	return 0;
 	return 0;
 }
 }
 
 
@@ -233,16 +229,16 @@ static int32_t sig_exit_handler (int num, void *data)
 static void sigsegv_handler (int num)
 static void sigsegv_handler (int num)
 {
 {
 	(void)signal (SIGSEGV, SIG_DFL);
 	(void)signal (SIGSEGV, SIG_DFL);
-	logsys_atexit();
-	logsys_log_rec_store (LOCALSTATEDIR "/lib/corosync/fdata");
+	qb_log_blackbox_write_to_file(LOCALSTATEDIR "/lib/corosync/fdata");
+	qb_log_fini();
 	raise (SIGSEGV);
 	raise (SIGSEGV);
 }
 }
 
 
 static void sigabrt_handler (int num)
 static void sigabrt_handler (int num)
 {
 {
 	(void)signal (SIGABRT, SIG_DFL);
 	(void)signal (SIGABRT, SIG_DFL);
-	logsys_atexit();
-	logsys_log_rec_store (LOCALSTATEDIR "/lib/corosync/fdata");
+	qb_log_blackbox_write_to_file(LOCALSTATEDIR "/lib/corosync/fdata");
+	qb_log_fini();
 	raise (SIGABRT);
 	raise (SIGABRT);
 }
 }
 
 
@@ -1033,6 +1029,39 @@ static void corosync_setscheduler (void)
 #endif
 #endif
 }
 }
 
 
+static void
+_logsys_log_printf(int level, int subsys,
+		const char *function_name,
+		const char *file_name,
+		int file_line,
+		const char *format,
+		...) __attribute__((format(printf, 6, 7)));
+
+static void
+_logsys_log_printf(int level, int subsys,
+		const char *function_name,
+		const char *file_name,
+		int file_line,
+		const char *format, ...)
+{
+	va_list ap;
+	char buf[QB_LOG_MAX_LEN];
+	size_t len;
+
+	va_start(ap, format);
+	len = vsnprintf(buf, sizeof(buf), format, ap);
+	va_end(ap);
+
+	if (buf[len - 1] == '\n') {
+		buf[len - 1] = '\0';
+		len -= 1;
+	}
+
+	qb_log_from_external_source(function_name, file_name,
+				    format, level, file_line,
+				    subsys, buf);
+}
+
 static void fplay_key_change_notify_fn (
 static void fplay_key_change_notify_fn (
 	object_change_type_t change_type,
 	object_change_type_t change_type,
 	hdb_handle_t parent_object_handle,
 	hdb_handle_t parent_object_handle,
@@ -1044,7 +1073,7 @@ static void fplay_key_change_notify_fn (
 {
 {
 	if (key_len == strlen ("dump_flight_data") &&
 	if (key_len == strlen ("dump_flight_data") &&
 		memcmp ("dump_flight_data", key_name_pt, key_len) == 0) {
 		memcmp ("dump_flight_data", key_name_pt, key_len) == 0) {
-		logsys_log_rec_store (LOCALSTATEDIR "/lib/corosync/fdata");
+		qb_log_blackbox_write_to_file (LOCALSTATEDIR "/lib/corosync/fdata");
 	}
 	}
 	if (key_len == strlen ("dump_state") &&
 	if (key_len == strlen ("dump_state") &&
 		memcmp ("dump_state", key_name_pt, key_len) == 0) {
 		memcmp ("dump_state", key_name_pt, key_len) == 0) {
@@ -1405,21 +1434,14 @@ int main (int argc, char **argv, char **envp)
 	}
 	}
 
 
 	totem_config.totem_logging_configuration = totem_logging_configuration;
 	totem_config.totem_logging_configuration = totem_logging_configuration;
-	totem_config.totem_logging_configuration.log_subsys_id =
-		_logsys_subsys_create ("TOTEM");
-
-	if (totem_config.totem_logging_configuration.log_subsys_id < 0) {
-		log_printf (LOGSYS_LEVEL_ERROR,
-			"Unable to initialize TOTEM logging subsystem\n");
-		corosync_exit_error (AIS_DONE_MAINCONFIGREAD);
-	}
-
+	totem_config.totem_logging_configuration.log_subsys_id = _logsys_subsys_create("TOTEM", "totem");
 	totem_config.totem_logging_configuration.log_level_security = LOGSYS_LEVEL_WARNING;
 	totem_config.totem_logging_configuration.log_level_security = LOGSYS_LEVEL_WARNING;
 	totem_config.totem_logging_configuration.log_level_error = LOGSYS_LEVEL_ERROR;
 	totem_config.totem_logging_configuration.log_level_error = LOGSYS_LEVEL_ERROR;
 	totem_config.totem_logging_configuration.log_level_warning = LOGSYS_LEVEL_WARNING;
 	totem_config.totem_logging_configuration.log_level_warning = LOGSYS_LEVEL_WARNING;
 	totem_config.totem_logging_configuration.log_level_notice = LOGSYS_LEVEL_NOTICE;
 	totem_config.totem_logging_configuration.log_level_notice = LOGSYS_LEVEL_NOTICE;
 	totem_config.totem_logging_configuration.log_level_debug = LOGSYS_LEVEL_DEBUG;
 	totem_config.totem_logging_configuration.log_level_debug = LOGSYS_LEVEL_DEBUG;
 	totem_config.totem_logging_configuration.log_printf = _logsys_log_printf;
 	totem_config.totem_logging_configuration.log_printf = _logsys_log_printf;
+	logsys_config_apply();
 
 
 	res = corosync_main_config_compatibility_read (objdb,
 	res = corosync_main_config_compatibility_read (objdb,
 		&minimum_sync_mode,
 		&minimum_sync_mode,
@@ -1448,7 +1470,7 @@ int main (int argc, char **argv, char **envp)
 	if (background) {
 	if (background) {
 		corosync_tty_detach ();
 		corosync_tty_detach ();
 	}
 	}
-	logsys_fork_completed();
+	qb_log_thread_start();
 
 
 	if ((flock_err = corosync_flock (corosync_lock_file, getpid ())) != AIS_DONE_EXIT) {
 	if ((flock_err = corosync_flock (corosync_lock_file, getpid ())) != AIS_DONE_EXIT) {
 		corosync_exit_error (flock_err);
 		corosync_exit_error (flock_err);

+ 4 - 3
exec/mainconfig.c

@@ -192,7 +192,7 @@ static int corosync_main_config_format_set (
 		if (strcmp (value, "on") == 0) {
 		if (strcmp (value, "on") == 0) {
 			if (!insert_into_buffer(new_format_buffer,
 			if (!insert_into_buffer(new_format_buffer,
 					sizeof(new_format_buffer),
 					sizeof(new_format_buffer),
-					" %f:%l", "s]")) {
+					" %f:%l", "g]")) {
 				err = logsys_format_set(new_format_buffer);
 				err = logsys_format_set(new_format_buffer);
 			} else
 			} else
 			if (!insert_into_buffer(new_format_buffer,
 			if (!insert_into_buffer(new_format_buffer,
@@ -217,7 +217,7 @@ static int corosync_main_config_format_set (
 			} else
 			} else
 			if (!insert_into_buffer(new_format_buffer,
 			if (!insert_into_buffer(new_format_buffer,
 					sizeof(new_format_buffer),
 					sizeof(new_format_buffer),
-					" %n", "s]")) {
+					" %n", "g]")) {
 				err = logsys_format_set(new_format_buffer);
 				err = logsys_format_set(new_format_buffer);
 			}
 			}
 		} else
 		} else
@@ -325,7 +325,7 @@ static int corosync_main_config_set (
 	 * handling requirements
 	 * handling requirements
 	 */
 	 */
 	if (subsys != NULL) {
 	if (subsys != NULL) {
-		if (_logsys_subsys_create(subsys) < 0) {
+		if (_logsys_subsys_create(subsys, NULL) < 0) {
 			error_reason = "unable to create new logging subsystem";
 			error_reason = "unable to create new logging subsystem";
 			goto parse_error;
 			goto parse_error;
 		}
 		}
@@ -559,6 +559,7 @@ static int corosync_main_config_read_logging (
 	}
 	}
 	objdb->object_find_destroy (object_find_handle);
 	objdb->object_find_destroy (object_find_handle);
 
 
+	logsys_config_apply();
 	return 0;
 	return 0;
 
 
 parse_error:
 parse_error:

+ 9 - 0
exec/service.c

@@ -176,6 +176,8 @@ unsigned int corosync_service_link_and_init (
 	char object_name[32];
 	char object_name[32];
 	char *name_sufix;
 	char *name_sufix;
 	uint64_t zero_64 = 0;
 	uint64_t zero_64 = 0;
+	void* _start;
+	void* _stop;
 
 
 	/*
 	/*
 	 * reference the service interface
 	 * reference the service interface
@@ -202,6 +204,13 @@ unsigned int corosync_service_link_and_init (
 	service = iface_ver0->corosync_get_service_engine_ver0();
 	service = iface_ver0->corosync_get_service_engine_ver0();
 
 
 	ais_service[service->id] = service;
 	ais_service[service->id] = service;
+
+	/* begin */
+	_start = lcr_ifact_addr_get(handle, "__start___verbose");
+	_stop = lcr_ifact_addr_get(handle, "__stop___verbose");
+	qb_log_callsites_register(_start, _stop);
+	/* end */
+
 	if (service->config_init_fn) {
 	if (service->config_init_fn) {
 		res = service->config_init_fn (corosync_api);
 		res = service->config_init_fn (corosync_api);
 	}
 	}

+ 1 - 1
exec/syncv2.c

@@ -185,7 +185,7 @@ int sync_v2_init (
 		NULL);
 		NULL);
 	if (res == -1) {
 	if (res == -1) {
 		log_printf (LOGSYS_LEVEL_ERROR,
 		log_printf (LOGSYS_LEVEL_ERROR,
-			"Couldn't initialize groups interface.\n");
+			"Couldn't initialize groups interface.");
 		return (-1);
 		return (-1);
 	}
 	}
 
 

+ 2 - 2
exec/totemconfig.c

@@ -756,7 +756,7 @@ static int read_keyfile (
 
 
 	fd = open (key_location, O_RDONLY);
 	fd = open (key_location, O_RDONLY);
 	if (fd == -1) {
 	if (fd == -1) {
-		LOGSYS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
+		error_ptr = qb_strerror_r(errno, error_str, sizeof(error_str));
 		snprintf (error_string_response, sizeof(error_string_response),
 		snprintf (error_string_response, sizeof(error_string_response),
 			"Could not open %s: %s\n",
 			"Could not open %s: %s\n",
 			 key_location, error_ptr);
 			 key_location, error_ptr);
@@ -768,7 +768,7 @@ static int read_keyfile (
 	close (fd);
 	close (fd);
 
 
 	if (res == -1) {
 	if (res == -1) {
-		LOGSYS_STRERROR_R (error_ptr, saved_errno, error_str, sizeof(error_str));
+		error_ptr = qb_strerror_r (saved_errno, error_str, sizeof(error_str));
 		snprintf (error_string_response, sizeof(error_string_response),
 		snprintf (error_string_response, sizeof(error_string_response),
 			"Could not read %s: %s\n",
 			"Could not read %s: %s\n",
 			 key_location, error_ptr);
 			 key_location, error_ptr);

+ 7 - 8
exec/totemiba.c

@@ -210,14 +210,13 @@ union u {
 	void *v;
 	void *v;
 };
 };
 
 
-#define log_printf(level, format, args...)				\
-do {									\
-        instance->totemiba_log_printf (					\
-		LOGSYS_ENCODE_RECID(level,				\
-				    instance->totemiba_subsys_id,	\
-				    LOGSYS_RECID_LOG),			\
-                __FUNCTION__, __FILE__, __LINE__,			\
-		(const char *)format, ##args);				\
+#define log_printf(level, format, args...)			\
+do {								\
+        instance->totemiba_log_printf (				\
+			level,					\
+			instance->totemiba_subsys_id,		\
+			__FUNCTION__, __FILE__, __LINE__,	\
+			(const char *)format, ##args);		\
 } while (0);
 } while (0);
 
 
 struct recv_buf {
 struct recv_buf {

+ 4 - 4
exec/totemnet.c

@@ -204,12 +204,13 @@ struct totemnet_instance {
 	struct transport *transport;
 	struct transport *transport;
 
 
         void (*totemnet_log_printf) (
         void (*totemnet_log_printf) (
-                unsigned int rec_ident,
+                int level,
+		int subsys,
                 const char *function,
                 const char *function,
                 const char *file,
                 const char *file,
                 int line,
                 int line,
                 const char *format,
                 const char *format,
-                ...)__attribute__((format(printf, 5, 6)));
+                ...)__attribute__((format(printf, 6, 7)));
 
 
         int totemnet_subsys_id;
         int totemnet_subsys_id;
 };
 };
@@ -217,9 +218,8 @@ struct totemnet_instance {
 #define log_printf(level, format, args...)				\
 #define log_printf(level, format, args...)				\
 do {									\
 do {									\
 	instance->totemnet_log_printf (					\
 	instance->totemnet_log_printf (					\
-		LOGSYS_ENCODE_RECID(level,				\
+		level,							\
 		instance->totemnet_subsys_id,				\
 		instance->totemnet_subsys_id,				\
-		LOGSYS_RECID_LOG),					\
 		__FUNCTION__, __FILE__, __LINE__,			\
 		__FUNCTION__, __FILE__, __LINE__,			\
 		(const char *)format, ##args);				\
 		(const char *)format, ##args);				\
 } while (0);
 } while (0);

+ 9 - 10
exec/totempg.c

@@ -176,11 +176,12 @@ static int totempg_log_level_notice;
 static int totempg_log_level_debug;
 static int totempg_log_level_debug;
 static int totempg_subsys_id;
 static int totempg_subsys_id;
 static void (*totempg_log_printf) (
 static void (*totempg_log_printf) (
-	unsigned int rec_ident,
+	int level,
+	int subsys,
 	const char *function,
 	const char *function,
 	const char *file,
 	const char *file,
 	int line,
 	int line,
-	const char *format, ...) __attribute__((format(printf, 5, 6)));
+	const char *format, ...) __attribute__((format(printf, 6, 7)));
 
 
 struct totem_config *totempg_totem_config;
 struct totem_config *totempg_totem_config;
 
 
@@ -259,14 +260,12 @@ static pthread_mutex_t callback_token_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 
 static pthread_mutex_t mcast_msg_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t mcast_msg_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 
-#define log_printf(level, format, args...)				\
-do {									\
-        totempg_log_printf (						\
-		LOGSYS_ENCODE_RECID(level,				\
-				    totempg_subsys_id,			\
-				    LOGSYS_RECID_LOG),			\
-		__FUNCTION__, __FILE__, __LINE__,			\
-		format, ##args);					\
+#define log_printf(level, format, args...)			\
+do {								\
+        totempg_log_printf(level,				\
+			   totempg_subsys_id,			\
+			   __FUNCTION__, __FILE__, __LINE__,	\
+			   format, ##args);			\
 } while (0);
 } while (0);
 
 
 static int msg_count_send_ok (int msg_count);
 static int msg_count_send_ok (int msg_count);

+ 9 - 10
exec/totemrrp.c

@@ -228,11 +228,12 @@ struct totemrrp_instance {
 	int totemrrp_subsys_id;
 	int totemrrp_subsys_id;
 
 
 	void (*totemrrp_log_printf) (
 	void (*totemrrp_log_printf) (
-		unsigned int rec_ident,
+		int level,
+		int subsys,
 		const char *function,
 		const char *function,
 		const char *file,
 		const char *file,
 		int line,
 		int line,
-		const char *format, ...)__attribute__((format(printf, 5, 6)));
+		const char *format, ...)__attribute__((format(printf, 6, 7)));
 
 
 	void **net_handles;
 	void **net_handles;
 
 
@@ -589,14 +590,12 @@ struct rrp_algo *rrp_algos[] = {
 
 
 #define RRP_ALGOS_COUNT 3
 #define RRP_ALGOS_COUNT 3
 
 
-#define log_printf(level, format, args...)				\
-do {									\
-	rrp_instance->totemrrp_log_printf (				\
-		LOGSYS_ENCODE_RECID(level,				\
-				    rrp_instance->totemrrp_subsys_id,	\
-				    LOGSYS_RECID_LOG),			\
-		__FUNCTION__, __FILE__, __LINE__,			\
-		format, ##args);					\
+#define log_printf(level, format, args...)			\
+do {								\
+	rrp_instance->totemrrp_log_printf (			\
+		level, rrp_instance->totemrrp_subsys_id,	\
+		__FUNCTION__, __FILE__, __LINE__,		\
+		format, ##args);				\
 } while (0);
 } while (0);
 
 
 static void test_active_msg_endian_convert(const struct message_header *in, struct message_header *out)
 static void test_active_msg_endian_convert(const struct message_header *in, struct message_header *out)

+ 18 - 10
exec/totemsrp.c

@@ -438,11 +438,12 @@ struct totemsrp_instance {
 	int totemsrp_subsys_id;
 	int totemsrp_subsys_id;
 
 
 	void (*totemsrp_log_printf) (
 	void (*totemsrp_log_printf) (
-		unsigned int rec_ident,
+		int level,
+		int sybsys,
 		const char *function,
 		const char *function,
 		const char *file,
 		const char *file,
 		int line,
 		int line,
-		const char *format, ...)__attribute__((format(printf, 5, 6)));;
+		const char *format, ...)__attribute__((format(printf, 6, 7)));;
 
 
 	enum memb_state memb_state;
 	enum memb_state memb_state;
 
 
@@ -639,15 +640,22 @@ struct message_handlers totemsrp_message_handlers = {
 
 
 static const char *rundir = NULL;
 static const char *rundir = NULL;
 
 
-#define log_printf(level, format, args...)				\
-do {									\
-	instance->totemsrp_log_printf (					\
-		LOGSYS_ENCODE_RECID(level,				\
-				   instance->totemsrp_subsys_id,	\
-				   LOGSYS_RECID_LOG),			\
-		__FUNCTION__, __FILE__, __LINE__,			\
-		format, ##args);					\
+#define log_printf(level, format, args...)		\
+do {							\
+	instance->totemsrp_log_printf (			\
+		level, instance->totemsrp_subsys_id,	\
+		__FUNCTION__, __FILE__, __LINE__,	\
+		format, ##args);			\
 } while (0);
 } while (0);
+#define LOGSYS_PERROR(err_num, level, fmt, args...)						\
+do {												\
+	char _error_str[LOGSYS_MAX_PERROR_MSG_LEN];						\
+	const char *_error_ptr = qb_strerror_r(err_num, _error_str, sizeof(_error_str));	\
+        instance->totemsrp_log_printf (								\
+		level, instance->totemsrp_subsys_id,						\
+                __FUNCTION__, __FILE__, __LINE__,						\
+		fmt ": %s (%d)\n", ##args, _error_ptr, err_num);				\
+	} while(0)
 
 
 static void totemsrp_instance_initialize (struct totemsrp_instance *instance)
 static void totemsrp_instance_initialize (struct totemsrp_instance *instance)
 {
 {

+ 14 - 5
exec/totemudp.c

@@ -159,12 +159,13 @@ struct totemudp_instance {
 	int totemudp_subsys_id;
 	int totemudp_subsys_id;
 
 
 	void (*totemudp_log_printf) (
 	void (*totemudp_log_printf) (
-		unsigned int rec_ident,
+		int level,
+		int subsys,
 		const char *function,
 		const char *function,
 		const char *file,
 		const char *file,
 		int line,
 		int line,
 		const char *format,
 		const char *format,
-		...)__attribute__((format(printf, 5, 6)));
+		...)__attribute__((format(printf, 6, 7)));
 
 
 	void *udp_context;
 	void *udp_context;
 
 
@@ -244,13 +245,21 @@ static void totemudp_instance_initialize (struct totemudp_instance *instance)
 #define log_printf(level, format, args...)				\
 #define log_printf(level, format, args...)				\
 do {									\
 do {									\
         instance->totemudp_log_printf (					\
         instance->totemudp_log_printf (					\
-		LOGSYS_ENCODE_RECID(level,				\
-				    instance->totemudp_subsys_id,	\
-				    LOGSYS_RECID_LOG),			\
+		level, instance->totemudp_subsys_id,			\
                 __FUNCTION__, __FILE__, __LINE__,			\
                 __FUNCTION__, __FILE__, __LINE__,			\
 		(const char *)format, ##args);				\
 		(const char *)format, ##args);				\
 } while (0);
 } while (0);
 
 
+#define LOGSYS_PERROR(err_num, level, fmt, args...)						\
+do {												\
+	char _error_str[LOGSYS_MAX_PERROR_MSG_LEN];						\
+	const char *_error_ptr = qb_strerror_r(err_num, _error_str, sizeof(_error_str));	\
+        instance->totemudp_log_printf (								\
+		level, instance->totemudp_subsys_id,						\
+                __FUNCTION__, __FILE__, __LINE__,						\
+		fmt ": %s (%d)\n", ##args, _error_ptr, err_num);				\
+	} while(0)
+
 
 
 static int authenticate_and_decrypt_sober (
 static int authenticate_and_decrypt_sober (
 	struct totemudp_instance *instance,
 	struct totemudp_instance *instance,

+ 18 - 10
exec/totemudpu.c

@@ -154,12 +154,13 @@ struct totemudpu_instance {
 	int totemudpu_subsys_id;
 	int totemudpu_subsys_id;
 
 
 	void (*totemudpu_log_printf) (
 	void (*totemudpu_log_printf) (
-		unsigned int rec_ident,
+		int level,
+		int subsys,
 		const char *function,
 		const char *function,
 		const char *file,
 		const char *file,
 		int line,
 		int line,
 		const char *format,
 		const char *format,
-		...)__attribute__((format(printf, 5, 6)));
+		...)__attribute__((format(printf, 6, 7)));
 
 
 	void *udpu_context;
 	void *udpu_context;
 
 
@@ -227,15 +228,22 @@ static void totemudpu_instance_initialize (struct totemudpu_instance *instance)
 	list_init (&instance->member_list);
 	list_init (&instance->member_list);
 }
 }
 
 
-#define log_printf(level, format, args...)				\
-do {									\
-        instance->totemudpu_log_printf (					\
-		LOGSYS_ENCODE_RECID(level,				\
-				    instance->totemudpu_subsys_id,	\
-				    LOGSYS_RECID_LOG),			\
-                __FUNCTION__, __FILE__, __LINE__,			\
-		(const char *)format, ##args);				\
+#define log_printf(level, format, args...)		\
+do {							\
+        instance->totemudpu_log_printf (		\
+		level, instance->totemudpu_subsys_id,	\
+                __FUNCTION__, __FILE__, __LINE__,	\
+		(const char *)format, ##args);		\
 } while (0);
 } while (0);
+#define LOGSYS_PERROR(err_num, level, fmt, args...)						\
+do {												\
+	char _error_str[LOGSYS_MAX_PERROR_MSG_LEN];						\
+	const char *_error_ptr = qb_strerror_r(err_num, _error_str, sizeof(_error_str));	\
+        instance->totemudpu_log_printf (							\
+		level, instance->totemudpu_subsys_id,						\
+                __FUNCTION__, __FILE__, __LINE__,						\
+		fmt ": %s (%d)\n", ##args, _error_ptr, err_num);				\
+	} while(0)
 
 
 static int authenticate_and_decrypt_sober (
 static int authenticate_and_decrypt_sober (
 	struct totemudpu_instance *instance,
 	struct totemudpu_instance *instance,

+ 1 - 1
exec/util.c

@@ -143,7 +143,7 @@ void _corosync_exit_error (
 	log_printf (LOGSYS_LEVEL_ERROR, "Corosync Cluster Engine exiting "
 	log_printf (LOGSYS_LEVEL_ERROR, "Corosync Cluster Engine exiting "
 		"with status %d at %s:%u.\n", err, file, line);
 		"with status %d at %s:%u.\n", err, file, line);
 
 
-	logsys_atexit ();
+	qb_log_fini();
 	exit (err);
 	exit (err);
 }
 }
 
 

+ 35 - 270
include/corosync/engine/logsys.h

@@ -43,6 +43,8 @@
 #include <pthread.h>
 #include <pthread.h>
 #include <limits.h>
 #include <limits.h>
 
 
+#include <qb/qblog.h>
+
 #ifdef __cplusplus
 #ifdef __cplusplus
 extern "C" {
 extern "C" {
 #endif
 #endif
@@ -70,34 +72,6 @@ extern "C" {
 #define LOGSYS_LEVEL_INFO		LOG_INFO
 #define LOGSYS_LEVEL_INFO		LOG_INFO
 #define LOGSYS_LEVEL_DEBUG		LOG_DEBUG
 #define LOGSYS_LEVEL_DEBUG		LOG_DEBUG
 
 
-/*
- * All of the LOGSYS_RECID's are mutually exclusive. Only one RECID at any time
- * can be specified.
- *
- * RECID_LOG indicates a message that should be sent to log. Anything else
- * is stored only in the flight recorder.
- */
-
-#define LOGSYS_RECID_MAX		((UINT_MAX) >> LOGSYS_SUBSYSID_END)
-
-#define LOGSYS_RECID_LOG		(LOGSYS_RECID_MAX - 1)
-#define LOGSYS_RECID_ENTER		(LOGSYS_RECID_MAX - 2)
-#define LOGSYS_RECID_LEAVE		(LOGSYS_RECID_MAX - 3)
-#define LOGSYS_RECID_TRACE1		(LOGSYS_RECID_MAX - 4)
-#define LOGSYS_RECID_TRACE2		(LOGSYS_RECID_MAX - 5)
-#define LOGSYS_RECID_TRACE3		(LOGSYS_RECID_MAX - 6)
-#define LOGSYS_RECID_TRACE4		(LOGSYS_RECID_MAX - 7)
-#define LOGSYS_RECID_TRACE5		(LOGSYS_RECID_MAX - 8)
-#define LOGSYS_RECID_TRACE6		(LOGSYS_RECID_MAX - 9)
-#define LOGSYS_RECID_TRACE7		(LOGSYS_RECID_MAX - 10)
-#define LOGSYS_RECID_TRACE8		(LOGSYS_RECID_MAX - 11)
-
-
-/*
- * Internal APIs that must be globally exported
- * (External API below)
- */
-
 /*
 /*
  * logsys_logger bits
  * logsys_logger bits
  *
  *
@@ -106,147 +80,10 @@ extern "C" {
  */
  */
 #define LOGSYS_MAX_SUBSYS_COUNT		64
 #define LOGSYS_MAX_SUBSYS_COUNT		64
 #define LOGSYS_MAX_SUBSYS_NAMELEN	64
 #define LOGSYS_MAX_SUBSYS_NAMELEN	64
-
-/*
- * rec_ident explained:
- *
- * rec_ident is an unsigned int and carries bitfields information
- * on subsys_id, log priority (level) and type of message (RECID).
- *
- * level values are imported from syslog.h.
- * At the time of writing it's a 3 bits value (0 to 7).
- *
- * subsys_id is any value between 0 and 64 (LOGSYS_MAX_SUBSYS_COUNT)
- *
- * RECID identifies the type of message. A set of predefined values
- * are available via logsys, but other custom values can be defined
- * by users.
- *
- * ----
- * bitfields:
- *
- * 0  - 2 level
- * 3  - 9 subsysid
- * 10 - n RECID
- */
-
-#define LOGSYS_LEVEL_END		(3)
-#define LOGSYS_SUBSYSID_END		(LOGSYS_LEVEL_END + 7)
-
-#define LOGSYS_RECID_LEVEL_MASK		(LOG_PRIMASK)
-#define LOGSYS_RECID_SUBSYSID_MASK	((2 << (LOGSYS_SUBSYSID_END - 1)) - \
-					(LOG_PRIMASK + 1))
-#define LOGSYS_RECID_RECID_MASK		(UINT_MAX - \
-					(LOGSYS_RECID_SUBSYSID_MASK + LOG_PRIMASK))
-
-#define LOGSYS_ENCODE_RECID(level,subsysid,recid) \
-	(((recid) << LOGSYS_SUBSYSID_END) | \
-	((subsysid) << LOGSYS_LEVEL_END) | \
-	(level))
-
-#define LOGSYS_DECODE_LEVEL(rec_ident) \
-	((rec_ident) & LOGSYS_RECID_LEVEL_MASK)
-
-#define LOGSYS_DECODE_SUBSYSID(rec_ident) \
-	(((rec_ident) & LOGSYS_RECID_SUBSYSID_MASK) >> LOGSYS_LEVEL_END)
-
-#define LOGSYS_DECODE_RECID(rec_ident) \
-	(((rec_ident) & LOGSYS_RECID_RECID_MASK) >> LOGSYS_SUBSYSID_END)
-
 #define LOGSYS_MAX_PERROR_MSG_LEN	128
 #define LOGSYS_MAX_PERROR_MSG_LEN	128
 
 
-#ifdef COROSYNC_LINUX
-/* The GNU version of strerror_r returns a (char*) that *must* be used */
-#define LOGSYS_STRERROR_R(out_ptr, err_num, buffer, sizeof_buffer) \
-	out_ptr = strerror_r(err_num, buffer, sizeof_buffer);
-#else
-/* The XSI-compliant strerror_r() return 0 or -1 (in case the buffer is full) */
-#define LOGSYS_STRERROR_R(out_ptr, err_num, buffer, sizeof_buffer) do {	\
-		if ( strerror_r(err_num, buffer, sizeof_buffer) == 0 ) {		\
-			out_ptr = buffer;											\
-		} else {														\
-			out_ptr = "";												\
-		}																\
-	} while(0)
-#endif
-
-#define LOGSYS_PERROR(err_num, level, fmt, args...) do {							\
-		char _error_str[LOGSYS_MAX_PERROR_MSG_LEN];									\
-		const char *_error_ptr;														\
-		LOGSYS_STRERROR_R(_error_ptr, err_num, _error_str, sizeof(_error_str));		\
-		log_printf(level, fmt ": %s (%d)\n", ##args, _error_ptr, err_num);			\
-	} while(0)
-
-
-
 #ifndef LOGSYS_UTILS_ONLY
 #ifndef LOGSYS_UTILS_ONLY
 
 
-extern int _logsys_system_setup(
-	const char *mainsystem,
-	unsigned int mode,
-	unsigned int debug,
-	const char *logfile,
-	int logfile_priority,
-	int syslog_facility,
-	int syslog_priority);
-
-extern int _logsys_config_subsys_get (
-	const char *subsys);
-
-extern int _logsys_subsys_create (const char *subsys);
-
-extern int _logsys_rec_init (unsigned int size);
-
-extern void _logsys_log_vprintf (
-	unsigned int rec_ident,
-	const char *function_name,
-	const char *file_name,
-	int file_line,
-	const char *format,
-	va_list ap) __attribute__((format(printf, 5, 0)));
-
-extern void _logsys_log_printf (
-	unsigned int rec_ident,
-	const char *function_name,
-	const char *file_name,
-	int file_line,
-	const char *format,
-	...) __attribute__((format(printf, 5, 6)));
-
-extern void _logsys_log_rec (
-	unsigned int rec_ident,
-	const char *function_name,
-	const char *file_name,
-	int file_line,
-	...);
-
-extern int _logsys_wthread_create (void);
-
-static int logsys_subsys_id __attribute__((unused)) = LOGSYS_MAX_SUBSYS_COUNT;
-
-/*
- * External API - init
- * See below:
- *
- * LOGSYS_DECLARE_SYSTEM
- * LOGSYS_DECLARE_SUBSYS
- *
- */
-extern void logsys_fork_completed (void);
-
-extern void logsys_atexit (void);
-
-/*
- * External API - misc
- */
-extern void logsys_flush (void);
-
-extern int logsys_log_rec_store (const char *filename);
-
-/*
- * External API - configuration
- */
-
 /*
 /*
  * configuration bits that can only be done for the whole system
  * configuration bits that can only be done for the whole system
  */
  */
@@ -278,6 +115,8 @@ extern int logsys_config_mode_set (
 extern unsigned int logsys_config_mode_get (
 extern unsigned int logsys_config_mode_get (
 	const char *subsys);
 	const char *subsys);
 
 
+void logsys_config_apply(void);
+
 /*
 /*
  * to close a logfile, just invoke this function with a NULL
  * to close a logfile, just invoke this function with a NULL
  * file or if you want to change logfile, the old one will
  * file or if you want to change logfile, the old one will
@@ -318,46 +157,27 @@ extern int logsys_priority_id_get (
 extern const char *logsys_priority_name_get (
 extern const char *logsys_priority_name_get (
 	unsigned int priority);
 	unsigned int priority);
 
 
-extern int logsys_thread_priority_set (
-	int policy,
-	const struct sched_param *param,
-	unsigned int after_log_ops_yield);
+extern int _logsys_system_setup(
+	const char *mainsystem,
+	unsigned int mode,
+	int syslog_facility,
+	int syslog_priority);
 
 
-/*
- * External definitions
- */
-extern void *logsys_rec_end;
+extern int _logsys_config_subsys_get (
+	const char *subsys);
 
 
-#define LOGSYS_REC_END (&logsys_rec_end)
+extern int _logsys_subsys_create (const char *subsys, const char *filename);
 
 
-#define LOGSYS_DECLARE_SYSTEM(name,mode,debug,file,file_priority,	\
-		syslog_facility,syslog_priority,format,fltsize)		\
+static int logsys_subsys_id __attribute__((unused)) = LOGSYS_MAX_SUBSYS_COUNT;
+
+#define LOGSYS_DECLARE_SYSTEM(name,mode,syslog_facility,syslog_priority)\
 __attribute__ ((constructor))						\
 __attribute__ ((constructor))						\
 static void logsys_system_init (void)					\
 static void logsys_system_init (void)					\
 {									\
 {									\
-	if (_logsys_system_setup (name,mode,debug,file,file_priority,	\
-			syslog_facility,syslog_priority) < 0) {		\
+	if (_logsys_system_setup (name,mode,syslog_facility,syslog_priority) < 0) { \
 		fprintf (stderr,					\
 		fprintf (stderr,					\
 			"Unable to setup logging system: %s.\n", name);	\
 			"Unable to setup logging system: %s.\n", name);	\
 		exit (-1);						\
 		exit (-1);						\
-	}								\
-									\
-	if (logsys_format_set (format) == -1) {				\
-		fprintf (stderr,					\
-			"Unable to setup logging format.\n");		\
-		exit (-1);						\
-	}								\
-									\
-	if (_logsys_rec_init (fltsize) < 0) {				\
-		fprintf (stderr,					\
-			"Unable to initialize log flight recorder.\n");	\
-		exit (-1);						\
-	}								\
-									\
-	if (_logsys_wthread_create() < 0) {				\
-		fprintf (stderr,					\
-			"Unable to initialize logging thread.\n");	\
-		exit (-1);						\
 	}								\
 	}								\
 }
 }
 
 
@@ -365,8 +185,9 @@ static void logsys_system_init (void)					\
 __attribute__ ((constructor))						\
 __attribute__ ((constructor))						\
 static void logsys_subsys_init (void)					\
 static void logsys_subsys_init (void)					\
 {									\
 {									\
+	assert(__start___verbose != __stop___verbose);			\
 	logsys_subsys_id =						\
 	logsys_subsys_id =						\
-		_logsys_subsys_create ((subsys));			\
+		_logsys_subsys_create ((subsys), __FILE__);		\
 	if (logsys_subsys_id == -1) {					\
 	if (logsys_subsys_id == -1) {					\
 		fprintf (stderr,					\
 		fprintf (stderr,					\
 		"Unable to create logging subsystem: %s.\n", subsys);	\
 		"Unable to create logging subsystem: %s.\n", subsys);	\
@@ -374,79 +195,23 @@ static void logsys_subsys_init (void)					\
 	}								\
 	}								\
 }
 }
 
 
-#define log_rec(rec_ident, args...)					\
-do {									\
-	_logsys_log_rec (rec_ident,  __FUNCTION__,			\
-		__FILE__,  __LINE__, ##args,				\
-		LOGSYS_REC_END);					\
-} while(0)
-
-#define log_printf(level, format, args...)				\
- do {									\
-	_logsys_log_printf (						\
-		LOGSYS_ENCODE_RECID(level,				\
-				    logsys_subsys_id,			\
-				    LOGSYS_RECID_LOG),			\
-		 __FUNCTION__, __FILE__, __LINE__,			\
-		format, ##args);					\
-} while(0)
-
-#define ENTER() do {							\
-	_logsys_log_rec (						\
-		LOGSYS_ENCODE_RECID(LOGSYS_LEVEL_DEBUG,			\
-				    logsys_subsys_id,			\
-				    LOGSYS_RECID_ENTER),		\
-		__FUNCTION__, __FILE__,  __LINE__, LOGSYS_REC_END);	\
-} while(0)
-
-#define LEAVE() do {							\
-	_logsys_log_rec (						\
-		LOGSYS_ENCODE_RECID(LOGSYS_LEVEL_DEBUG,			\
-				    logsys_subsys_id,			\
-				    LOGSYS_RECID_LEAVE),		\
-		__FUNCTION__, __FILE__,  __LINE__, LOGSYS_REC_END);	\
-} while(0)
-
-#define TRACE(recid, format, args...) do {				\
-	_logsys_log_printf (						\
-		LOGSYS_ENCODE_RECID(LOGSYS_LEVEL_DEBUG,			\
-				    logsys_subsys_id,			\
-				    recid),				\
-		 __FUNCTION__, __FILE__, __LINE__,			\
-		format, ##args);					\
-} while(0)
-
-#define TRACE1(format, args...) do {					\
-	TRACE(LOGSYS_RECID_TRACE1, format, ##args);			\
-} while(0)
-
-#define TRACE2(format, args...) do {					\
-	TRACE(LOGSYS_RECID_TRACE2, format, ##args);			\
-} while(0)
-
-#define TRACE3(format, args...) do {					\
-	TRACE(LOGSYS_RECID_TRACE3, format, ##args);			\
-} while(0)
-
-#define TRACE4(format, args...) do {					\
-	TRACE(LOGSYS_RECID_TRACE4, format, ##args);			\
-} while(0)
-
-#define TRACE5(format, args...) do {					\
-	TRACE(LOGSYS_RECID_TRACE5, format, ##args);			\
-} while(0)
-
-#define TRACE6(format, args...) do {					\
-	TRACE(LOGSYS_RECID_TRACE6, format, ##args);			\
-} while(0)
-
-#define TRACE7(format, args...) do {					\
-	TRACE(LOGSYS_RECID_TRACE7, format, ##args);			\
-} while(0)
-
-#define TRACE8(format, args...) do {					\
-	TRACE(LOGSYS_RECID_TRACE8, format, ##args);			\
-} while(0)
+#define LOGSYS_PERROR(err_num, level, fmt, args...) do {						\
+		char _error_str[LOGSYS_MAX_PERROR_MSG_LEN];						\
+		const char *_error_ptr = qb_strerror_r(err_num, _error_str, sizeof(_error_str));	\
+		qb_log(level, fmt ": %s (%d)\n", ##args, _error_ptr, err_num);				\
+	} while(0)
+
+#define log_printf(level, format, args...) qb_log(level, format, ##args)
+#define ENTER() qb_log(LOG_DEBUG, "ENTER")
+#define LEAVE() qb_log(LOG_DEBUG, "LEAVE")
+#define TRACE1(format, args...) qb_log(LOG_DEBUG, "TRACE1:" #format, ##args)
+#define TRACE2
+#define TRACE3
+#define TRACE4
+#define TRACE5
+#define TRACE6
+#define TRACE7
+#define TRACE8
 
 
 #endif /* LOGSYS_UTILS_ONLY */
 #endif /* LOGSYS_UTILS_ONLY */
 
 

+ 3 - 0
include/corosync/lcr/lcr_ifact.h

@@ -44,6 +44,9 @@ int lcr_ifact_reference (
 	void **interface,
 	void **interface,
 	void *context);
 	void *context);
 
 
+void *lcr_ifact_addr_get(hdb_handle_t iface_handle,
+			 const char* symbol_name);
+
 int lcr_ifact_release (
 int lcr_ifact_release (
 	hdb_handle_t handle);
 	hdb_handle_t handle);
 
 

+ 3 - 10
include/corosync/totem/totem.h

@@ -69,12 +69,13 @@ struct totem_interface {
 
 
 struct totem_logging_configuration {
 struct totem_logging_configuration {
 	void (*log_printf) (
 	void (*log_printf) (
-		unsigned int rec_ident,
+		int level,
+		int subsys,
 		const char *function_name,
 		const char *function_name,
 		const char *file_name,
 		const char *file_name,
 		int file_line,
 		int file_line,
 		const char *format,
 		const char *format,
-		...) __attribute__((format(printf, 5, 6)));
+		...) __attribute__((format(printf, 6, 7)));
 
 
 	int log_level_security;
 	int log_level_security;
 	int log_level_error;
 	int log_level_error;
@@ -148,14 +149,6 @@ struct totem_config {
 
 
 	struct totem_logging_configuration totem_logging_configuration;
 	struct totem_logging_configuration totem_logging_configuration;
 
 
-	void (*log_rec) (
-		int subsysid,
-		const char *function_name,
-		const char *file_name,
-		int file_line,
-		unsigned int rec_ident,
-		...);
-
 	unsigned int secauth;
 	unsigned int secauth;
 
 
 	unsigned int net_mtu;
 	unsigned int net_mtu;

+ 24 - 0
lcr/lcr_ifact.c

@@ -456,6 +456,30 @@ found:
 
 
 static unsigned int lcr_initialized = 0;
 static unsigned int lcr_initialized = 0;
 
 
+void *lcr_ifact_addr_get(hdb_handle_t iface_handle,
+			 const char* symbol_name)
+{
+	struct lcr_iface_instance *iface_instance;
+	struct lcr_component_instance *instance;
+	void *ptr;
+
+	hdb_handle_get (&lcr_iface_instance_database,
+		iface_handle, (void *)&iface_instance);
+
+	hdb_handle_get (&lcr_component_instance_database,
+		iface_instance->component_handle, (void *)&instance);
+
+	ptr = dlsym(instance->dl_handle, symbol_name);
+
+	hdb_handle_put(&lcr_component_instance_database,
+		iface_instance->component_handle);
+
+	hdb_handle_put (&lcr_iface_instance_database,
+		iface_handle);
+	return ptr;
+}
+
+
 int lcr_ifact_reference (
 int lcr_ifact_reference (
 	hdb_handle_t *iface_handle,
 	hdb_handle_t *iface_handle,
 	const char *iface_name,
 	const char *iface_name,

+ 4 - 4
services/cpg.c

@@ -748,9 +748,9 @@ static int notify_lib_joinlist(
 	return CS_OK;
 	return CS_OK;
 }
 }
 
 
-static void downlist_log(int loglevel, const char *msg, struct downlist_msg* dl)
+static void downlist_log(const char *msg, struct downlist_msg* dl)
 {
 {
-	log_printf (loglevel,
+	log_printf (LOG_DEBUG,
 		    "%s: sender %s; members(old:%d left:%d)",
 		    "%s: sender %s; members(old:%d left:%d)",
 		    msg,
 		    msg,
 		    api->totem_ifaces_print(dl->sender_nodeid),
 		    api->totem_ifaces_print(dl->sender_nodeid),
@@ -771,7 +771,7 @@ static struct downlist_msg* downlist_master_choose (void)
 		iter = iter->next) {
 		iter = iter->next) {
 
 
 		cmp = list_entry(iter, struct downlist_msg, list);
 		cmp = list_entry(iter, struct downlist_msg, list);
-		downlist_log(LOGSYS_LEVEL_DEBUG, "comparing", cmp);
+		downlist_log("comparing", cmp);
 		if (best == NULL) {
 		if (best == NULL) {
 			best = cmp;
 			best = cmp;
 			continue;
 			continue;
@@ -807,7 +807,7 @@ static void downlist_master_choose_and_send (void)
 		log_printf (LOGSYS_LEVEL_DEBUG, "NO chosen downlist");
 		log_printf (LOGSYS_LEVEL_DEBUG, "NO chosen downlist");
 		return;
 		return;
 	}
 	}
-	downlist_log(LOGSYS_LEVEL_DEBUG, "chosen downlist", stored_msg);
+	downlist_log("chosen downlist", stored_msg);
 
 
 	/* send events */
 	/* send events */
 	for (iter = process_info_list_head.next; iter != &process_info_list_head; ) {
 	for (iter = process_info_list_head.next; iter != &process_info_list_head; ) {

+ 6 - 10
test/Makefile.am

@@ -34,10 +34,10 @@ MAINTAINERCLEANFILES    = Makefile.in
 INCLUDES       		= -I$(top_builddir)/include/corosync -I$(top_srcdir)/include
 INCLUDES       		= -I$(top_builddir)/include/corosync -I$(top_srcdir)/include
 
 
 noinst_PROGRAMS		= testevs evsbench evsverify cpgverify testcpg testcpg2 cpgbench testconfdb	\
 noinst_PROGRAMS		= testevs evsbench evsverify cpgverify testcpg testcpg2 cpgbench testconfdb	\
-			logsysbench logsysrec testquorum testvotequorum1 testvotequorum2	\
-			logsys_s logsys_t1 logsys_t2 \
+			testquorum testvotequorum1 testvotequorum2	\
 			stress_cpgfdget stress_cpgcontext cpgbound testsam \
 			stress_cpgfdget stress_cpgcontext cpgbound testsam \
-			testcpgzc cpgbenchzc testzcgc stress_cpgzc 
+			testcpgzc cpgbenchzc testzcgc stress_cpgzc \
+			logsys_s logsys_t1 logsys_t2
 
 
 testevs_LDADD		= -levs $(LIBQB_LIBS)
 testevs_LDADD		= -levs $(LIBQB_LIBS)
 testevs_LDFLAGS		= -L../lib
 testevs_LDFLAGS		= -L../lib
@@ -75,16 +75,12 @@ cpgbench_LDADD		= -lcpg $(LIBQB_LIBS)
 cpgbench_LDFLAGS	= -L../lib
 cpgbench_LDFLAGS	= -L../lib
 cpgbenchzc_LDADD	= -lcpg $(LIBQB_LIBS)
 cpgbenchzc_LDADD	= -lcpg $(LIBQB_LIBS)
 cpgbenchzc_LDFLAGS	= -L../lib
 cpgbenchzc_LDFLAGS	= -L../lib
-logsysbench_LDADD	= -llogsys
-logsysbench_LDFLAGS	= -L../exec
-logsysrec_LDADD		= -llogsys
-logsysrec_LDFLAGS	= -L../exec
 logsys_s_SOURCES	= logsys_s.c logsys_s1.c logsys_s2.c
 logsys_s_SOURCES	= logsys_s.c logsys_s1.c logsys_s2.c
-logsys_s_LDADD		= -llogsys
+logsys_s_LDADD		= -llogsys  $(LIBQB_LIBS)
 logsys_s_LDFLAGS	= -L../exec
 logsys_s_LDFLAGS	= -L../exec
-logsys_t1_LDADD		= -llogsys
+logsys_t1_LDADD		= -llogsys  $(LIBQB_LIBS)
 logsys_t1_LDFLAGS	= -L../exec
 logsys_t1_LDFLAGS	= -L../exec
-logsys_t2_LDADD		= -llogsys
+logsys_t2_LDADD		= -llogsys  $(LIBQB_LIBS)
 logsys_t2_LDFLAGS	= -L../exec
 logsys_t2_LDFLAGS	= -L../exec
 testsam_LDADD		= -lsam -lconfdb -lquorum $(LIBQB_LIBS)
 testsam_LDADD		= -lsam -lconfdb -lquorum $(LIBQB_LIBS)
 testsam_LDFLAGS		= -L../lib
 testsam_LDFLAGS		= -L../lib

+ 4 - 7
test/logsys_s.c

@@ -36,24 +36,21 @@
 
 
 #include <stdio.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <syslog.h>
+#include <assert.h>
 
 
 #include <corosync/engine/logsys.h>
 #include <corosync/engine/logsys.h>
 
 
 LOGSYS_DECLARE_SYSTEM ("logsystestsubsystems",
 LOGSYS_DECLARE_SYSTEM ("logsystestsubsystems",
 	LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_OUTPUT_SYSLOG,
 	LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_OUTPUT_SYSLOG,
-	0,
-	NULL,
-	LOGSYS_LEVEL_INFO,
 	LOG_DAEMON,
 	LOG_DAEMON,
-	LOGSYS_LEVEL_INFO,
-	NULL,
-	1000000);
+	LOGSYS_LEVEL_INFO);
+LOGSYS_DECLARE_SUBSYS ("MAIN");
 
 
 extern void logsys_s1_print (void);
 extern void logsys_s1_print (void);
 extern void logsys_s2_print (void);
 extern void logsys_s2_print (void);
 
 
 int main (void) {
 int main (void) {
-	logsys_fork_completed();
+	qb_log_thread_start();
 	logsys_s1_print();
 	logsys_s1_print();
 	logsys_s2_print();
 	logsys_s2_print();
 	return (0);
 	return (0);

+ 1 - 0
test/logsys_s1.c

@@ -36,6 +36,7 @@
 
 
 #include <stdio.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <syslog.h>
+#include <assert.h>
 
 
 #include <corosync/engine/logsys.h>
 #include <corosync/engine/logsys.h>
 
 

+ 1 - 0
test/logsys_s2.c

@@ -36,6 +36,7 @@
 
 
 #include <stdio.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <syslog.h>
+#include <assert.h>
 
 
 #include <corosync/engine/logsys.h>
 #include <corosync/engine/logsys.h>
 
 

+ 3 - 6
test/logsys_t1.c

@@ -36,18 +36,15 @@
 
 
 #include <stdio.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <syslog.h>
+#include <assert.h>
 
 
 #include <corosync/engine/logsys.h>
 #include <corosync/engine/logsys.h>
 
 
 LOGSYS_DECLARE_SYSTEM ("logsystestNOsubsystems",
 LOGSYS_DECLARE_SYSTEM ("logsystestNOsubsystems",
 	LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_OUTPUT_SYSLOG,
 	LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_OUTPUT_SYSLOG,
-	0,
-	NULL,
-	LOGSYS_LEVEL_DEBUG,
 	LOG_DAEMON,
 	LOG_DAEMON,
-	LOGSYS_LEVEL_DEBUG,
-	NULL,
-	1000000);
+	LOGSYS_LEVEL_DEBUG);
+LOGSYS_DECLARE_SUBSYS("MAIN");
 
 
 int main (void) {
 int main (void) {
 	log_printf (LOGSYS_LEVEL_ALERT, "This is an alert log message\n");
 	log_printf (LOGSYS_LEVEL_ALERT, "This is an alert log message\n");

+ 8 - 6
test/logsys_t2.c

@@ -36,18 +36,16 @@
 
 
 #include <stdio.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <stdint.h>
+#include <assert.h>
 
 
 #include <corosync/engine/logsys.h>
 #include <corosync/engine/logsys.h>
 
 
 LOGSYS_DECLARE_SYSTEM ("logtest_t2",
 LOGSYS_DECLARE_SYSTEM ("logtest_t2",
 	LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_THREADED,
 	LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_THREADED,
-	0,
-	NULL,
-	LOGSYS_LEVEL_INFO,
 	LOG_DAEMON,
 	LOG_DAEMON,
-	LOGSYS_LEVEL_INFO,
-	NULL,
-	1000000);
+	LOGSYS_LEVEL_INFO);
+
+LOGSYS_DECLARE_SUBSYS("MAIN");
 
 
 int
 int
 main(int argc, char **argv)
 main(int argc, char **argv)
@@ -57,21 +55,25 @@ main(int argc, char **argv)
 	 */
 	 */
 	logsys_config_mode_set (NULL, LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_THREADED);
 	logsys_config_mode_set (NULL, LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_THREADED);
 
 
+
 	log_printf(LOGSYS_LEVEL_NOTICE, "Hello, world!\n");
 	log_printf(LOGSYS_LEVEL_NOTICE, "Hello, world!\n");
 	log_printf(LOGSYS_LEVEL_DEBUG, "If you see this, the logger's busted\n");
 	log_printf(LOGSYS_LEVEL_DEBUG, "If you see this, the logger's busted\n");
 
 
 	logsys_config_logfile_priority_set (NULL, LOGSYS_LEVEL_ALERT);
 	logsys_config_logfile_priority_set (NULL, LOGSYS_LEVEL_ALERT);
+	logsys_config_apply();
 
 
 	log_printf(LOGSYS_LEVEL_DEBUG, "If you see this, the logger's busted\n");
 	log_printf(LOGSYS_LEVEL_DEBUG, "If you see this, the logger's busted\n");
 	log_printf(LOGSYS_LEVEL_CRIT, "If you see this, the logger's busted\n");
 	log_printf(LOGSYS_LEVEL_CRIT, "If you see this, the logger's busted\n");
 	log_printf(LOGSYS_LEVEL_ALERT, "Alert 1\n");
 	log_printf(LOGSYS_LEVEL_ALERT, "Alert 1\n");
 
 
 	logsys_config_logfile_priority_set (NULL, LOGSYS_LEVEL_NOTICE);
 	logsys_config_logfile_priority_set (NULL, LOGSYS_LEVEL_NOTICE);
+	logsys_config_apply();
 
 
 	log_printf(LOGSYS_LEVEL_CRIT, "Crit 1\n");
 	log_printf(LOGSYS_LEVEL_CRIT, "Crit 1\n");
 	log_printf(LOGSYS_LEVEL_INFO, "If you see this, the logger's busted\n");
 	log_printf(LOGSYS_LEVEL_INFO, "If you see this, the logger's busted\n");
 
 
 	logsys_config_logfile_priority_set (NULL, LOGSYS_LEVEL_DEBUG);
 	logsys_config_logfile_priority_set (NULL, LOGSYS_LEVEL_DEBUG);
+	logsys_config_apply();
 
 
 	log_printf(LOGSYS_LEVEL_DEBUG, "Debug 1\n");
 	log_printf(LOGSYS_LEVEL_DEBUG, "Debug 1\n");
 
 

+ 0 - 177
test/logsysbench.c

@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 2008, 2009 Red Hat, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake@redhat.com)
- *
- * This software licensed under BSD license, the text of which follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- *   this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * - Neither the name of the MontaVista Software, Inc. nor the names of its
- *   contributors may be used to endorse or promote products derived from this
- *   software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <sys/time.h>
-#include <time.h>
-#include <corosync/engine/logsys.h>
-
-LOGSYS_DECLARE_SYSTEM ("logtest_rec",
-	LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_THREADED,
-	0,                /* debug */
-	NULL,
-	LOGSYS_LEVEL_INFO,   /* logfile_priority */
-	LOG_DAEMON,       /* syslog facility */
-	LOGSYS_LEVEL_INFO,   /* syslog level */
-	NULL,             /* use default format */
-	1000000);         /* flight recorder size */
-
-#define LOGREC_ID_CHECKPOINT_CREATE 2
-#define LOGREC_ARGS_CHECKPOINT_CREATE 2
-#define ITERATIONS 1000000
-
-static struct timeval tv1, tv2, tv_elapsed;
-
-#ifndef timersub
-#define timersub(a, b, result)					\
-do {								\
-	(result)->tv_sec = (a)->tv_sec - (b)->tv_sec;		\
-	(result)->tv_usec = (a)->tv_usec - (b)->tv_usec;	\
-	if ((result)->tv_usec < 0) {				\
-		--(result)->tv_sec;				\
-		(result)->tv_usec += 1000000;			\
-	}							\
-} while (0)
-#endif
-
-static void bm_start (void)
-{
-        gettimeofday (&tv1, NULL);
-}
-static void bm_finish (const char *operation)
-{
-        gettimeofday (&tv2, NULL);
-        timersub (&tv2, &tv1, &tv_elapsed);
-
-	if (strlen (operation) > 22) {
-        	printf ("%s\t\t", operation);
-	} else {
-        	printf ("%s\t\t\t", operation);
-	}
-        printf ("%9.3f operations/sec\n",
-                ((float)ITERATIONS) /  (tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)));
-}
-
-static char buffer[256];
-int main (void)
-{
-	int i;
-	char buf[1024];
-
-
-	printf ("heating up cache with logrec functionality\n");
-	for (i = 0; i < ITERATIONS; i++) {
-	log_rec (LOGREC_ID_CHECKPOINT_CREATE,
-		"recordA", 8, "recordB", 8, LOGSYS_REC_END);
-	}
-	bm_start();
-	for (i = 0; i < ITERATIONS; i++) {
-	log_rec (LOGREC_ID_CHECKPOINT_CREATE,
-		buffer, 7, LOGSYS_REC_END);
-	}
-	bm_finish ("log_rec 1 arguments:");
-	bm_start();
-	for (i = 0; i < ITERATIONS; i++) {
-	log_rec (LOGREC_ID_CHECKPOINT_CREATE,
-		"recordA", 8, LOGSYS_REC_END);
-	}
-	bm_finish ("log_rec 2 arguments:");
-	bm_start();
-	for (i = 0; i < 10; i++) {
-	log_rec (LOGREC_ID_CHECKPOINT_CREATE,
-		"recordA", 8, "recordB", 8, LOGSYS_REC_END);
-	}
-	bm_start();
-	for (i = 0; i < ITERATIONS; i++) {
-	log_rec (LOGREC_ID_CHECKPOINT_CREATE,
-		"recordA", 8, "recordB", 8, "recordC", 8, LOGSYS_REC_END);
-	}
-	bm_finish ("log_rec 3 arguments:");
-	bm_start();
-	for (i = 0; i < ITERATIONS; i++) {
-	log_rec (LOGREC_ID_CHECKPOINT_CREATE,
-		"recordA", 8, "recordB", 8, "recordC", 8, "recordD", 8, LOGSYS_REC_END);
-	}
-	bm_finish ("log_rec 4 arguments:");
-
-	/*
-	 * sprintf testing
-	 */
-	printf ("heating up cache with sprintf functionality\n");
-	for (i = 0; i < ITERATIONS; i++) {
-		snprintf (buf, sizeof(buf), "Some logging information %s", "recordA");
-	}
-	bm_start();
-	for (i = 0; i < ITERATIONS; i++) {
-		snprintf (buf, sizeof(buf), "Some logging information %s", "recordA");
-	}
-	bm_finish ("sprintf 1 argument:");
-	bm_start();
-	for (i = 0; i < ITERATIONS; i++) {
-		sprintf (buf, "Some logging information %s %s", "recordA", "recordB");
-	}
-	bm_finish ("sprintf 2 arguments:");
-	bm_start();
-	for (i = 0; i < ITERATIONS; i++) {
-		sprintf (buf, "Some logging information %s %s %s", "recordA", "recordB", "recordC");
-	}
-	bm_finish ("sprintf 3 arguments:");
-	bm_start();
-	for (i = 0; i < ITERATIONS; i++) {
-		sprintf (buf, "Some logging information %s %s %s %s", "recordA", "recordB", "recordC", "recordD");
-	}
-	bm_finish ("sprintf 4 arguments:");
-	bm_start();
-	for (i = 0; i < ITERATIONS; i++) {
-		sprintf (buf, "Some logging information %s %s %s %d", "recordA", "recordB", "recordC", i);
-	}
-	bm_finish ("sprintf 4 arguments (1 int):");
-
-	logsys_log_rec_store ("fdata");
-/* TODO
-	currently fails under some circumstances
-
-	bm_start();
-	for (i = 0; i < ITERATIONS; i++) {
-	log_printf (LOGSYS_LEVEL_NOTICE, "test %d", i);
-	}
-	bm_finish("log_printf");
-*/
-
-	return (0);
-}

+ 1 - 6
test/logsysrec.c

@@ -40,13 +40,8 @@
 
 
 LOGSYS_DECLARE_SYSTEM ("logtest_rec",
 LOGSYS_DECLARE_SYSTEM ("logtest_rec",
 	LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_THREADED,
 	LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_THREADED,
-	0,
-	NULL,
-	LOG_INFO,
 	LOG_DAEMON,
 	LOG_DAEMON,
-	LOG_INFO,
-	NULL,
-	100000);
+	LOG_INFO);
 
 
 #define LOGREC_ID_CHECKPOINT_CREATE 2
 #define LOGREC_ID_CHECKPOINT_CREATE 2
 #define LOGREC_ARGS_CHECKPOINT_CREATE 2
 #define LOGREC_ARGS_CHECKPOINT_CREATE 2

+ 42 - 513
tools/corosync-fplay.c

@@ -1,522 +1,51 @@
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <errno.h>
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-
-#include <corosync/engine/logsys.h>
-
-uint32_t flt_data_size;
-
-uint32_t *flt_data;
-#define FDHEAD_INDEX		(flt_data_size)
-#define FDTAIL_INDEX		(flt_data_size + 1)
-
-#define TOTEMIP_ADDRLEN (sizeof(struct in6_addr))
-
-struct totem_ip_address {
-        unsigned int   nodeid;
-        unsigned short family;
-        unsigned char  addr[TOTEMIP_ADDRLEN];
-} __attribute__((packed));
-
-struct memb_ring_id {
-        struct totem_ip_address rep;
-        unsigned long long seq;
-} __attribute__((packed));
-
-static const char *totemip_print(const struct totem_ip_address *addr)
-{
-	static char buf[INET6_ADDRSTRLEN];
-
-	return inet_ntop(addr->family, addr->addr, buf, sizeof(buf));
-}
-
-static char *print_string_len (const unsigned char *str, unsigned int len)
-{
-	unsigned int i;
-	static char buf[1024];
-	memset (buf, 0, sizeof (buf));
-	for (i = 0; i < len; i++) {
-		buf[i] = str[i];
-	}
-	return (buf);
-}
-
-static void sync_printer_confchg_set_sync (const void **record)
-{
-	const unsigned int *my_should_sync = record[0];
-	printf ("Setting my_should_sync to %d\n", *my_should_sync);
-}
-
-static void sync_printer_set_sync_state (const void **record)
-{
-	const unsigned int *my_sync_state = record[0];
-	printf ("Setting my_sync_state to %d\n", *my_sync_state);
-}
-
-static void sync_printer_process_currentstate (const void **record)
-{
-	const unsigned int *my_sync_state = record[0];
-	printf ("Retrieving my_sync_state %d\n", *my_sync_state);
-}
-
-static void sync_printer_process_get_shouldsync (const void **record)
-{
-	const unsigned int *my_should_sync = record[0];
-	printf ("Getting my_should_sync %d\n", *my_should_sync);
-}
-
-static void sync_printer_checkpoint_release (const void **record)
-{
-	const unsigned char *name = record[0];
-	const uint16_t *name_len = record[1];
-	const unsigned int *ckpt_id = record[2];
-	const unsigned int *from = record[3];
-
-	printf ("Checkpoint release name=[%s] id=[%d] from=[%d] len=[%d]\n",
-		print_string_len (name, *name_len),
-		*ckpt_id,
-		*from,
-		*name_len);
-}
-
-static void sync_printer_checkpoint_transmit (const void **record)
-{
-	const unsigned char *name = record[0];
-	const uint16_t *name_len = record[1];
-	const unsigned int *ckpt_id = record[2];
-	const unsigned int *xmit_id = record[3];
-
-	printf ("xmit_id=[%d] Checkpoint transmit name=[%s] id=[%d]\n",
-		*xmit_id, print_string_len (name, *name_len),
-		*ckpt_id);
-}
-
-static void sync_printer_section_transmit (const void **record)
-{
-	const unsigned char *ckpt_name = record[0];
-	const uint16_t *name_len = record[1];
-	const unsigned int *ckpt_id = record[2];
-	const unsigned int *xmit_id = record[3];
-	const unsigned char *section_name = record[4];
-	const uint16_t *section_name_len = record[5];
-
-	printf ("xmit_id=[%d] Section transmit checkpoint name=[%s] id=[%d] ",
-		*xmit_id, print_string_len (ckpt_name, *name_len),
-		*ckpt_id);
-	printf ("section=[%s]\n",
-		print_string_len (section_name, *section_name_len));
-}
-static void sync_printer_checkpoint_receive (const void **record)
-{
-	const unsigned char *ckpt_name = record[0];
-	const uint16_t *name_len = record[1];
-	const unsigned int *ckpt_id = record[2];
-	const unsigned int *xmit_id = record[3];
-
-	printf ("xmit_id=[%d] Checkpoint receive checkpoint name=[%s] id=[%d]\n",
-		*xmit_id, print_string_len (ckpt_name, *name_len), *ckpt_id);
-}
-
-static void sync_printer_section_receive (const void **record)
-{
-	const unsigned char *ckpt_name = record[0];
-	const uint16_t *name_len = record[1];
-	const unsigned int *ckpt_id = record[2];
-	const unsigned int *xmit_id = record[3];
-	const unsigned char *section_name = record[4];
-	const unsigned int *section_name_len = record[5];
-
-	printf ("xmit_id=[%d] Section receive checkpoint name=[%s] id=[%d] ",
-		*xmit_id, print_string_len (ckpt_name, *name_len),
-		*ckpt_id);
-
-	printf ("section=[%s]\n",
-		print_string_len (section_name, *section_name_len));
-}
-
-static void sync_printer_confchg_fn (const void **record)
-{
-	unsigned int i;
-
-	const unsigned int *members = record[0];
-	const unsigned int *member_count = record[1];
-	const struct memb_ring_id *ring_id = record[2];
-	struct in_addr addr;
-
-	printf ("sync confchg fn ringid [ip=%s seq=%lld]\n",
-		totemip_print (&ring_id->rep),
-		ring_id->seq);
-	printf ("members [%d]:\n", *member_count);
-	for (i = 0; i < *member_count; i++) {
-		addr.s_addr = members[i];
-		printf ("\tmember [%s]\n", inet_ntoa (addr));
-	}
-}
-
-static void printer_totemsrp_mcast (const void **record)
-{
-	const unsigned int *msgid = record[0];
-
-	printf ("totemsrp_mcast %d\n", *msgid);
-}
-
-static void printer_totemsrp_delv (const void **record)
-{
-	const unsigned int *msgid = record[0];
-
-	printf ("totemsrp_delv %d\n", *msgid);
-}
-
-static void printer_totempg_mcast_fits (const void **record)
-{
-	const unsigned int *idx = record[0];
-	const unsigned int *iov_len = record[1];
-	const unsigned int *copy_len = record[2];
-	const unsigned int *fragment_size = record[3];
-	const unsigned int *max_packet_size = record[4];
-	const unsigned int *copy_base = record[5];
-	const unsigned char *next_fragment = record[6];
-
-	printf ("totempg_mcast index=[%d] iov_len=[%d] copy_len=[%d] fragment_size=[%d] max_packet_size=[%d] copy_base=[%d] next_fragment[%d]\n",
-	*idx, *iov_len, *copy_len, *fragment_size, *max_packet_size, *copy_base, *next_fragment);
-}
-
-static void sync_printer_service_process (const void **record)
-{
-	const struct memb_ring_id *ring_id = record[0];
-	const struct memb_ring_id *sync_ring_id = record[1];
-
-	printf ("sync service process callback ringid [ip=%s seq=%lld] ",
-		totemip_print (&ring_id->rep),
-		ring_id->seq);
-	printf ("sync ringid [ip=%s seq=%lld]\n",
-		totemip_print (&sync_ring_id->rep),
-		sync_ring_id->seq);
-}
-
-struct printer_subsys_record_print {
-	int ident;
-	void (*print_fn)(const void **record);
-	int record_length;
-};
-
-struct printer_subsys {
-	const char *subsys;
-	struct printer_subsys_record_print *record_printers;
-	int record_printers_count;
-};
-
-#define LOGREC_ID_SYNC_CONFCHG_FN 0
-#define LOGREC_ID_SYNC_SERVICE_PROCESS 1
-
 /*
 /*
- * CKPT subsystem
+ * Copyright (c) 2011 Red Hat
+ *
+ * All rights reserved.
+ *
+ * Author: Angus Salkeld <asalkeld@redhat.com>
+ *
+ * This software licensed under BSD license, the text of which follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * - Neither the name of the MontaVista Software, Inc. nor the names of its
+ *   contributors may be used to endorse or promote products derived from this
+ *   software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
  */
  */
-#define LOGREC_ID_CONFCHG_SETSYNC 0
-#define LOGREC_ID_SETSYNCSTATE 1
-#define LOGREC_ID_SYNC_PROCESS_CURRENTSTATE 2
-#define LOGREC_ID_SYNC_PROCESS_GETSHOULDSYNC 3
-#define LOGREC_ID_SYNC_CHECKPOINT_TRANSMIT 4
-#define LOGREC_ID_SYNC_SECTION_TRANSMIT 5
-#define LOGREC_ID_SYNC_CHECKPOINT_RECEIVE 6
-#define LOGREC_ID_SYNC_SECTION_RECEIVE 7
-#define LOGREC_ID_SYNC_CHECKPOINT_RELEASE 8
-
-#define LOGREC_ID_TOTEMSRP_MCAST 0
-#define LOGREC_ID_TOTEMSRP_DELV 1
-#define LOGREC_ID_TOTEMPG_MCAST_FITS 2
-
-
-static struct printer_subsys_record_print record_print_sync[] = {
-	{
-		.ident				= LOGREC_ID_SYNC_CONFCHG_FN,
-		.print_fn			= sync_printer_confchg_fn,
-		.record_length			= 28
-	},
-	{
-		.ident				= LOGREC_ID_SYNC_SERVICE_PROCESS,
-		.print_fn			= sync_printer_service_process,
-		.record_length			= 28
-	}
-};
-
-static struct printer_subsys_record_print record_print_ckpt[] = {
-	{
-		.ident				= LOGREC_ID_CONFCHG_SETSYNC,
-		.print_fn			= sync_printer_confchg_set_sync,
-		.record_length			= 28
-	},
-	{
-		.ident				= LOGREC_ID_SETSYNCSTATE,
-		.print_fn			= sync_printer_set_sync_state,
-		.record_length			= 28
-	},
-	{
-		.ident				= LOGREC_ID_SYNC_PROCESS_CURRENTSTATE,
-		.print_fn			= sync_printer_process_currentstate,
-		.record_length			= 28
-	},
-	{
-		.ident				= LOGREC_ID_SYNC_PROCESS_GETSHOULDSYNC,
-		.print_fn			= sync_printer_process_get_shouldsync,
-		.record_length			= 28
-	},
-	{
-		.ident				= LOGREC_ID_SYNC_CHECKPOINT_TRANSMIT,
-		.print_fn			= sync_printer_checkpoint_transmit,
-		.record_length			= 28
-	},
-	{
-		.ident				= LOGREC_ID_SYNC_SECTION_TRANSMIT,
-		.print_fn			= sync_printer_section_transmit,
-		.record_length			= 28
-	},
-	{
-		.ident				= LOGREC_ID_SYNC_CHECKPOINT_RECEIVE,
-		.print_fn			= sync_printer_checkpoint_receive,
-		.record_length			= 28
-	},
-	{
-		.ident				= LOGREC_ID_SYNC_SECTION_RECEIVE,
-		.print_fn			= sync_printer_section_receive,
-		.record_length			= 28
-	},
-	{
-		.ident				= LOGREC_ID_SYNC_CHECKPOINT_RELEASE,
-		.print_fn			= sync_printer_checkpoint_release,
-		.record_length			= 28
-	}
-
-};
-static struct printer_subsys_record_print record_print_totem[] = {
-	{
-		.ident				= LOGREC_ID_TOTEMSRP_MCAST,
-		.print_fn			= printer_totemsrp_mcast,
-		.record_length			= 28
-	},
-	{
-		.ident				= LOGREC_ID_TOTEMSRP_DELV,
-		.print_fn			= printer_totemsrp_delv,
-		.record_length			= 28
-	},
-	{
-		.ident				= LOGREC_ID_TOTEMPG_MCAST_FITS,
-		.print_fn			= printer_totempg_mcast_fits,
-		.record_length			= 28
-	}
-};
-
-static struct printer_subsys printer_subsystems[] = {
-	{
-		.subsys =			"SYNC",
-		.record_printers = 		record_print_sync,
-		.record_printers_count = 	sizeof (record_print_sync) / sizeof (struct printer_subsys_record_print)
-	},
-	{
-		.subsys =			"CKPT",
-		.record_printers = 		record_print_ckpt,
-		.record_printers_count = 	sizeof (record_print_ckpt) / sizeof (struct printer_subsys_record_print)
-	},
-	{
-		.subsys =			"TOTEM",
-		.record_printers = 		record_print_totem,
-		.record_printers_count = 	sizeof (record_print_totem) / sizeof (struct printer_subsys_record_print)
-	}
-};
 
 
-static unsigned int printer_subsys_count =
-  sizeof (printer_subsystems) / sizeof (struct printer_subsys);
-
-#define G_RECORD_SIZE	10000
-
-static uint32_t g_record[G_RECORD_SIZE];
-
-/*
- * Copy record, dealing with wrapping
- */
-static int logsys_rec_get (int rec_idx) {
-	uint32_t rec_size;
-	int firstcopy, secondcopy;
-
-	rec_size = flt_data[rec_idx];
-
-	firstcopy = rec_size;
-	secondcopy = 0;
-
-	if (rec_size > G_RECORD_SIZE || rec_size > flt_data_size) {
-		fprintf (stderr, "rec_size too large. Input file is probably corrupted.\n");
-		exit (EXIT_FAILURE);
-	}
-
-	if (firstcopy + rec_idx > flt_data_size) {
-		firstcopy = flt_data_size - rec_idx;
-		secondcopy -= firstcopy - rec_size;
-	}
-	memcpy (&g_record[0], &flt_data[rec_idx], firstcopy * sizeof(uint32_t));
-	if (secondcopy) {
-		memcpy (&g_record[firstcopy], &flt_data[0], secondcopy * sizeof(uint32_t));
-	}
-	return ((rec_idx + rec_size) % flt_data_size);
-}
-
-static void logsys_rec_print (const void *record)
-{
-	const uint32_t *buf_uint32t = record;
-	uint32_t rec_size;
-	uint32_t rec_ident;
-	uint32_t line;
-	uint32_t arg_size_idx;
-	unsigned int i;
-	unsigned int j;
-	unsigned int rec_idx = 0;
-	uint32_t record_number;
-	unsigned int words_processed;
-	const char *arguments[64];
-	int arg_count = 0;
-
-	rec_size = buf_uint32t[rec_idx];
-	rec_ident = buf_uint32t[rec_idx+1];
-	line = buf_uint32t[rec_idx+2];
-	record_number = buf_uint32t[rec_idx+3];
-
-	printf ("rec=[%d] ", record_number);
-	arg_size_idx = rec_idx + 4;
-	words_processed = 4;
-	for (i = 0; words_processed < rec_size; i++) {
-		arguments[arg_count++] =
-		  (const char *)&buf_uint32t[arg_size_idx + 1];
-		words_processed += buf_uint32t[arg_size_idx] + 1;
-		arg_size_idx += buf_uint32t[arg_size_idx] + 1;
-
-	}
-
-	for (i = 0; i < printer_subsys_count; i++) {
-		if (strcmp (arguments[0], printer_subsystems[i].subsys) == 0) {
-			for (j = 0; j < printer_subsystems[i].record_printers_count; j++) {
-				if (rec_ident == printer_subsystems[i].record_printers[j].ident) {
-				  printer_subsystems[i].record_printers[j].print_fn ((const void **)&arguments[3]);
-					return;
-				}
-			}
-		}
-	}
-
-	switch(LOGSYS_DECODE_RECID(rec_ident)) {
-		case LOGSYS_RECID_LOG:
-			printf ("Log Message=%s\n", arguments[3]);
-			break;
-		case LOGSYS_RECID_ENTER:
-			printf ("ENTERING function [%s] line [%d]\n", arguments[2], line);
-			break;
-		case LOGSYS_RECID_LEAVE:
-			printf ("LEAVING function [%s] line [%d]\n", arguments[2], line);
-			break;
-		case LOGSYS_RECID_TRACE1:
-			printf ("Tracing(1) Messsage=%s\n", arguments[3]);
-			break;
-		case LOGSYS_RECID_TRACE2:
-			printf ("Tracing(2) Messsage=%s\n", arguments[3]);
-			break;
-		case LOGSYS_RECID_TRACE3:
-			printf ("Tracing(3) Messsage=%s\n", arguments[3]);
-			break;
-		case LOGSYS_RECID_TRACE4:
-			printf ("Tracing(4) Messsage=%s\n", arguments[3]);
-			break;
-		case LOGSYS_RECID_TRACE5:
-			printf ("Tracing(5) Messsage=%s\n", arguments[3]);
-			break;
-		case LOGSYS_RECID_TRACE6:
-			printf ("Tracing(6) Messsage=%s\n", arguments[3]);
-			break;
-		case LOGSYS_RECID_TRACE7:
-			printf ("Tracing(7) Messsage=%s\n", arguments[3]);
-			break;
-		case LOGSYS_RECID_TRACE8:
-			printf ("Tracing(8) Messsage=%s\n", arguments[3]);
-			break;
-		default:
-			printf ("Unknown record type found subsys=[%s] ident=[%d]\n",
-				arguments[0], LOGSYS_DECODE_RECID(rec_ident));
-			break;
-	}
-#ifdef COMPILE_OUT
-printf ("\n");
-#endif
-}
+#include "config.h"
+#include <qb/qbdefs.h>
+#include <qb/qblog.h>
 
 
 int main (void)
 int main (void)
 {
 {
-	int fd;
-	int rec_idx;
-	int end_rec;
-	int record_count = 1;
-	ssize_t n_read;
-	const char *data_file = LOCALSTATEDIR "/lib/corosync/fdata";
-	size_t n_required;
-
-	if ((fd = open (data_file, O_RDONLY)) < 0) {
-		fprintf (stderr, "failed to open %s: %s\n",
-			 data_file, strerror (errno));
-		return EXIT_FAILURE;
-	}
-
-	n_required = sizeof (uint32_t);
-	n_read = read (fd, &flt_data_size, n_required);
-	if (n_read != n_required) {
-		fprintf (stderr, "Unable to read fdata header\n");
-		return EXIT_FAILURE;
-	}
-
-	n_required = ((flt_data_size + 2) * sizeof(uint32_t));
-
-	if ((flt_data = malloc (n_required)) == NULL) {
-		fprintf (stderr, "exhausted virtual memory\n");
-		return EXIT_FAILURE;
-	}
-	n_read = read (fd, flt_data, n_required);
-	close (fd);
-	if (n_read < 0) {
-		fprintf (stderr, "reading %s failed: %s\n",
-			 data_file, strerror (errno));
-		return EXIT_FAILURE;
-	}
-
-	if (n_read != n_required) {
-		printf ("Warning: read %zd bytes, but expected %zu\n",
-			n_read, n_required);
-	}
-
-	rec_idx = flt_data[FDTAIL_INDEX];
-	end_rec = flt_data[FDHEAD_INDEX];
-
-	printf ("Starting replay: head [%d] tail [%d]\n",
-		flt_data[FDHEAD_INDEX],
-		flt_data[FDTAIL_INDEX]);
+	qb_log_init("fplay", LOG_USER, LOG_INFO);
 
 
-	for (;;) {
-		rec_idx = logsys_rec_get (rec_idx);
-		logsys_rec_print (g_record);
-		if (rec_idx == end_rec) {
-			break;
-		}
-		record_count += 1;
-	}
+	qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD,
+			  QB_LOG_FILTER_FILE, __FILE__, LOG_INFO);
+	qb_log_format_set(QB_LOG_STDERR, "%f:%l [%p] %b");
+	qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_FALSE);
+	qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, QB_TRUE);
 
 
-	printf ("Finishing replay: records found [%d]\n", record_count);
-	return (0);
+	qb_log_blackbox_print_from_file(LOCALSTATEDIR "/lib/corosync/fdata");
+	return 0;
 }
 }

+ 68 - 66
tools/corosync-notifyd.c

@@ -49,7 +49,10 @@
 #include <ctype.h>
 #include <ctype.h>
 #include <poll.h>
 #include <poll.h>
 #include <signal.h>
 #include <signal.h>
-#include <syslog.h>
+
+#include <qb/qbdefs.h>
+#include <qb/qbloop.h>
+#include <qb/qblog.h>
 
 
 #include <qb/qbdefs.h>
 #include <qb/qbdefs.h>
 #include <qb/qbloop.h>
 #include <qb/qbloop.h>
@@ -200,7 +203,7 @@ static int32_t _cs_ip_to_hostname(char* ip, char* name_out)
 	rc = getnameinfo((struct sockaddr*)&sa, sizeof(sa),
 	rc = getnameinfo((struct sockaddr*)&sa, sizeof(sa),
 			name_out, CS_MAX_NAME_LENGTH, NULL, 0, 0);
 			name_out, CS_MAX_NAME_LENGTH, NULL, 0, 0);
 	if (rc != 0) {
 	if (rc != 0) {
-		syslog (LOG_ERR, "error looking up %s : %s\n", ip, gai_strerror(rc));
+		qb_log(LOG_ERR, 0, "error looking up %s : %s", ip, gai_strerror(rc));
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 	return 0;
 	return 0;
@@ -339,7 +342,7 @@ _cs_confdb_find_object (confdb_handle_t handle,
 	while (obj_name_pt != NULL) {
 	while (obj_name_pt != NULL) {
 		res = confdb_object_find_start(handle, parent_object_handle);
 		res = confdb_object_find_start(handle, parent_object_handle);
 		if (res != CS_OK) {
 		if (res != CS_OK) {
-			syslog (LOG_ERR, "Could not start object_find %d\n", res);
+			qb_log(LOG_ERR, 0, "Could not start object_find %d", res);
 			exit (EXIT_FAILURE);
 			exit (EXIT_FAILURE);
 		}
 		}
 
 
@@ -399,7 +402,7 @@ _cs_quorum_init(void)
 
 
 	rc = quorum_initialize (&quorum_handle, &quorum_callbacks);
 	rc = quorum_initialize (&quorum_handle, &quorum_callbacks);
 	if (rc != CS_OK) {
 	if (rc != CS_OK) {
-		syslog(LOG_ERR, "Could not connect to corosync(quorum)");
+		qb_log(LOG_ERR, "Could not connect to corosync(quorum)");
 		return;
 		return;
 	}
 	}
 	quorum_fd_get(quorum_handle, &fd);
 	quorum_fd_get(quorum_handle, &fd);
@@ -449,7 +452,7 @@ _cs_dbus_node_quorum_event(char *nodename, uint32_t nodeid, const char *state)
 	int ret = -1;
 	int ret = -1;
 
 
 	if (err_set) {
 	if (err_set) {
-		syslog (LOG_ERR, "%s\n", _err);
+		qb_log(LOG_ERR, "%s", _err);
 		err_set = 0;
 		err_set = 0;
 	}
 	}
 
 
@@ -469,7 +472,7 @@ _cs_dbus_node_quorum_event(char *nodename, uint32_t nodeid, const char *state)
 	if (!(msg = dbus_message_new_signal(DBUS_CS_PATH,
 	if (!(msg = dbus_message_new_signal(DBUS_CS_PATH,
 					    DBUS_CS_IFACE,
 					    DBUS_CS_IFACE,
 					    "QuorumStateChange"))) {
 					    "QuorumStateChange"))) {
-		syslog (LOG_ERR, "%s(%d) error\n", __func__, __LINE__);
+		qb_log(LOG_ERR, "error creating dbus signal");
 		goto out_unlock;
 		goto out_unlock;
 	}
 	}
 
 
@@ -478,7 +481,7 @@ _cs_dbus_node_quorum_event(char *nodename, uint32_t nodeid, const char *state)
 			DBUS_TYPE_UINT32, &nodeid,
 			DBUS_TYPE_UINT32, &nodeid,
 			DBUS_TYPE_STRING, &state,
 			DBUS_TYPE_STRING, &state,
 			DBUS_TYPE_INVALID)) {
 			DBUS_TYPE_INVALID)) {
-		syslog (LOG_ERR, "%s(%d) error\n", __func__, __LINE__);
+		qb_log(LOG_ERR, "error adding args to quorum signal");
 		goto out_unlock;
 		goto out_unlock;
 	}
 	}
 
 
@@ -486,11 +489,9 @@ _cs_dbus_node_quorum_event(char *nodename, uint32_t nodeid, const char *state)
 	ret = 0;
 	ret = 0;
 
 
 out_unlock:
 out_unlock:
-	if (ret == -1) {
-		syslog (LOG_ERR, "%s() error\n", __func__);
-	}
-	if (msg)
+	if (msg) {
 		dbus_message_unref(msg);
 		dbus_message_unref(msg);
+	}
 out_free:
 out_free:
 	return;
 	return;
 }
 }
@@ -502,7 +503,7 @@ _cs_dbus_node_membership_event(char *nodename, uint32_t nodeid, char *state, cha
 	int ret = -1;
 	int ret = -1;
 
 
 	if (err_set) {
 	if (err_set) {
-		syslog (LOG_ERR, "%s\n", _err);
+		qb_log(LOG_ERR, "%s", _err);
 		err_set = 0;
 		err_set = 0;
 	}
 	}
 
 
@@ -522,7 +523,7 @@ _cs_dbus_node_membership_event(char *nodename, uint32_t nodeid, char *state, cha
 	if (!(msg = dbus_message_new_signal(DBUS_CS_PATH,
 	if (!(msg = dbus_message_new_signal(DBUS_CS_PATH,
 					    DBUS_CS_IFACE,
 					    DBUS_CS_IFACE,
 					    "NodeStateChange"))) {
 					    "NodeStateChange"))) {
-		syslog (LOG_ERR, "%s(%d) error\n", __func__, __LINE__);
+		qb_log(LOG_ERR, "error creating NodeStateChange signal");
 		goto out_unlock;
 		goto out_unlock;
 	}
 	}
 
 
@@ -532,7 +533,7 @@ _cs_dbus_node_membership_event(char *nodename, uint32_t nodeid, char *state, cha
 			DBUS_TYPE_STRING, &ip,
 			DBUS_TYPE_STRING, &ip,
 			DBUS_TYPE_STRING, &state,
 			DBUS_TYPE_STRING, &state,
 			DBUS_TYPE_INVALID)) {
 			DBUS_TYPE_INVALID)) {
-		syslog (LOG_ERR, "%s(%d) error\n", __func__, __LINE__);
+		qb_log(LOG_ERR, "error adding args to NodeStateChange signal");
 		goto out_unlock;
 		goto out_unlock;
 	}
 	}
 
 
@@ -540,11 +541,9 @@ _cs_dbus_node_membership_event(char *nodename, uint32_t nodeid, char *state, cha
 	ret = 0;
 	ret = 0;
 
 
 out_unlock:
 out_unlock:
-	if (ret == -1) {
-		syslog (LOG_ERR, "%s() error\n", __func__);
-	}
-	if (msg)
+	if (msg) {
 		dbus_message_unref(msg);
 		dbus_message_unref(msg);
+	}
 out_free:
 out_free:
 	return;
 	return;
 }
 }
@@ -556,7 +555,7 @@ _cs_dbus_application_connection_event(char *nodename, uint32_t nodeid, char *app
 	int ret = -1;
 	int ret = -1;
 
 
 	if (err_set) {
 	if (err_set) {
-		syslog (LOG_ERR, "%s\n", _err);
+		qb_log(LOG_ERR, "%s", _err);
 		err_set = 0;
 		err_set = 0;
 	}
 	}
 
 
@@ -576,7 +575,7 @@ _cs_dbus_application_connection_event(char *nodename, uint32_t nodeid, char *app
 	if (!(msg = dbus_message_new_signal(DBUS_CS_PATH,
 	if (!(msg = dbus_message_new_signal(DBUS_CS_PATH,
 				DBUS_CS_IFACE,
 				DBUS_CS_IFACE,
 				"ConnectionStateChange"))) {
 				"ConnectionStateChange"))) {
-		syslog (LOG_ERR, "%s(%d) error\n", __func__, __LINE__);
+		qb_log(LOG_ERR, "error creating ConnectionStateChange signal");
 		goto out_unlock;
 		goto out_unlock;
 	}
 	}
 
 
@@ -586,7 +585,7 @@ _cs_dbus_application_connection_event(char *nodename, uint32_t nodeid, char *app
 			DBUS_TYPE_STRING, &app_name,
 			DBUS_TYPE_STRING, &app_name,
 			DBUS_TYPE_STRING, &state,
 			DBUS_TYPE_STRING, &state,
 			DBUS_TYPE_INVALID)) {
 			DBUS_TYPE_INVALID)) {
-		syslog (LOG_ERR, "%s(%d) error\n", __func__, __LINE__);
+		qb_log(LOG_ERR, "error adding args to ConnectionStateChange signal");
 		goto out_unlock;
 		goto out_unlock;
 	}
 	}
 
 
@@ -594,8 +593,9 @@ _cs_dbus_application_connection_event(char *nodename, uint32_t nodeid, char *app
 	ret = 0;
 	ret = 0;
 
 
 out_unlock:
 out_unlock:
-	if (msg)
+	if (msg) {
 		dbus_message_unref(msg);
 		dbus_message_unref(msg);
+	}
 out_free:
 out_free:
 	return;
 	return;
 }
 }
@@ -663,7 +663,7 @@ static netsnmp_session *snmp_init (const char *target)
 		NULL, NULL);
 		NULL, NULL);
 
 
 	if (session == NULL) {
 	if (session == NULL) {
-		syslog(LOG_ERR, "Could not create snmp transport");
+		qb_log(LOG_ERR, 0, "Could not create snmp transport");
 	}
 	}
 	return (session);
 	return (session);
 }
 }
@@ -694,13 +694,13 @@ _cs_snmp_node_membership_event(char *nodename, uint32_t nodeid, char *state, cha
 	netsnmp_pdu *trap_pdu;
 	netsnmp_pdu *trap_pdu;
 	netsnmp_session *session = snmp_init (snmp_manager);
 	netsnmp_session *session = snmp_init (snmp_manager);
 	if (session == NULL) {
 	if (session == NULL) {
-		syslog (LOG_NOTICE, "Failed to init SNMP session.\n");
+		qb_log(LOG_NOTICE, "Failed to init SNMP session.");
 		return ;
 		return ;
 	}
 	}
 
 
 	trap_pdu = snmp_pdu_create (SNMP_MSG_TRAP2);
 	trap_pdu = snmp_pdu_create (SNMP_MSG_TRAP2);
 	if (!trap_pdu) {
 	if (!trap_pdu) {
-		syslog (LOG_NOTICE, "Failed to create SNMP notification.\n");
+		qb_log(LOG_NOTICE, "Failed to create SNMP notification.");
 		return ;
 		return ;
 	}
 	}
 
 
@@ -719,7 +719,7 @@ _cs_snmp_node_membership_event(char *nodename, uint32_t nodeid, char *state, cha
 	ret = snmp_send (session, trap_pdu);
 	ret = snmp_send (session, trap_pdu);
 	if (ret == 0) {
 	if (ret == 0) {
 		/* error */
 		/* error */
-		syslog (LOG_ERR, "Could not send SNMP trap");
+		qb_log(LOG_ERR, "Could not send SNMP trap");
 		snmp_free_pdu (trap_pdu);
 		snmp_free_pdu (trap_pdu);
 	}
 	}
 }
 }
@@ -737,13 +737,13 @@ _cs_snmp_node_quorum_event(char *nodename, uint32_t nodeid,
 	netsnmp_pdu *trap_pdu;
 	netsnmp_pdu *trap_pdu;
 	netsnmp_session *session = snmp_init (snmp_manager);
 	netsnmp_session *session = snmp_init (snmp_manager);
 	if (session == NULL) {
 	if (session == NULL) {
-		syslog (LOG_NOTICE, "Failed to init SNMP session.\n");
+		qb_log(LOG_NOTICE, "Failed to init SNMP session.");
 		return ;
 		return ;
 	}
 	}
 
 
 	trap_pdu = snmp_pdu_create (SNMP_MSG_TRAP2);
 	trap_pdu = snmp_pdu_create (SNMP_MSG_TRAP2);
 	if (!trap_pdu) {
 	if (!trap_pdu) {
-		syslog (LOG_NOTICE, "Failed to create SNMP notification.\n");
+		qb_log(LOG_NOTICE, "Failed to create SNMP notification.");
 		return ;
 		return ;
 	}
 	}
 
 
@@ -761,7 +761,7 @@ _cs_snmp_node_quorum_event(char *nodename, uint32_t nodeid,
 	ret = snmp_send (session, trap_pdu);
 	ret = snmp_send (session, trap_pdu);
 	if (ret == 0) {
 	if (ret == 0) {
 		/* error */
 		/* error */
-		syslog (LOG_ERR, "Could not send SNMP trap");
+		qb_log(LOG_ERR, "Could not send SNMP trap");
 		snmp_free_pdu (trap_pdu);
 		snmp_free_pdu (trap_pdu);
 	}
 	}
 }
 }
@@ -787,16 +787,16 @@ _cs_snmp_init(void)
 static void
 static void
 _cs_syslog_node_membership_event(char *nodename, uint32_t nodeid, char *state, char* ip)
 _cs_syslog_node_membership_event(char *nodename, uint32_t nodeid, char *state, char* ip)
 {
 {
-	syslog (LOG_NOTICE, "%s[%d] ip:%s %s\n", nodename, nodeid, ip, state);
+	qb_log(LOG_NOTICE, "%s[%d] ip:%s %s", nodename, nodeid, ip, state);
 }
 }
 
 
 static void
 static void
 _cs_syslog_node_quorum_event(char *nodename, uint32_t nodeid, const char *state)
 _cs_syslog_node_quorum_event(char *nodename, uint32_t nodeid, const char *state)
 {
 {
 	if (strcmp(state, "quorate") == 0) {
 	if (strcmp(state, "quorate") == 0) {
-		syslog (LOG_NOTICE, "%s[%d] is now %s\n", nodename, nodeid, state);
+		qb_log(LOG_NOTICE, "%s[%d] is now %s", nodename, nodeid, state);
 	} else {
 	} else {
-		syslog (LOG_NOTICE, "%s[%d] has lost quorum\n", nodename, nodeid);
+		qb_log(LOG_NOTICE, "%s[%d] has lost quorum", nodename, nodeid);
 	}
 	}
 }
 }
 
 
@@ -804,9 +804,9 @@ static void
 _cs_syslog_application_connection_event(char *nodename, uint32_t nodeid, char* app_name, const char *state)
 _cs_syslog_application_connection_event(char *nodename, uint32_t nodeid, char* app_name, const char *state)
 {
 {
 	if (strcmp(state, "connected") == 0) {
 	if (strcmp(state, "connected") == 0) {
-		syslog (LOG_ERR, "%s[%d] %s is now %s to corosync\n", nodename, nodeid, app_name, state);
+		qb_log(LOG_NOTICE, "%s[%d] %s is now %s to corosync", nodename, nodeid, app_name, state);
 	} else {
 	} else {
-		syslog (LOG_ERR, "%s[%d] %s is now %s from corosync\n", nodename, nodeid, app_name, state);
+		qb_log(LOG_NOTICE, "%s[%d] %s is now %s from corosync", nodename, nodeid, app_name, state);
 	}
 	}
 }
 }
 
 
@@ -897,7 +897,7 @@ _cs_confdb_init(void)
 
 
 	rc = confdb_initialize (&confdb_handle, &callbacks);
 	rc = confdb_initialize (&confdb_handle, &callbacks);
 	if (rc != CS_OK) {
 	if (rc != CS_OK) {
-		syslog (LOG_ERR, "Failed to initialize the objdb API. Error %d\n", rc);
+		qb_log(LOG_ERR, "Failed to initialize the objdb API. Error %d", rc);
 		exit (EXIT_FAILURE);
 		exit (EXIT_FAILURE);
 	}
 	}
 	confdb_fd_get(confdb_handle, &conf_fd);
 	confdb_fd_get(confdb_handle, &conf_fd);
@@ -908,30 +908,30 @@ _cs_confdb_init(void)
 	rc = _cs_confdb_find_object (confdb_handle, "runtime.connections.",
 	rc = _cs_confdb_find_object (confdb_handle, "runtime.connections.",
 		&obj_handle);
 		&obj_handle);
 	if (rc != CS_OK) {
 	if (rc != CS_OK) {
-		syslog (LOG_ERR,
-			"Failed to find the connections object. Error %d\n", rc);
+		qb_log(LOG_ERR,
+			"Failed to find the connections object. Error %d", rc);
 		exit (EXIT_FAILURE);
 		exit (EXIT_FAILURE);
 	}
 	}
 
 
 	rc = confdb_track_changes (confdb_handle, obj_handle,
 	rc = confdb_track_changes (confdb_handle, obj_handle,
 		CONFDB_TRACK_DEPTH_ONE);
 		CONFDB_TRACK_DEPTH_ONE);
 	if (rc != CS_OK) {
 	if (rc != CS_OK) {
-		syslog (LOG_ERR,
-			"Failed to track the connections object. Error %d\n", rc);
+		qb_log(LOG_ERR,
+			"Failed to track the connections object. Error %d", rc);
 		exit (EXIT_FAILURE);
 		exit (EXIT_FAILURE);
 	}
 	}
 	rc = _cs_confdb_find_object(confdb_handle,
 	rc = _cs_confdb_find_object(confdb_handle,
 		"runtime.totem.pg.mrp.srp.members.", &obj_handle);
 		"runtime.totem.pg.mrp.srp.members.", &obj_handle);
 	if (rc != CS_OK) {
 	if (rc != CS_OK) {
-		syslog (LOG_ERR, "Failed to find the object. Error %d\n", rc);
+		qb_log(LOG_ERR, "Failed to find the object. Error %d", rc);
 		exit (EXIT_FAILURE);
 		exit (EXIT_FAILURE);
 	}
 	}
 
 
 	rc = confdb_track_changes(confdb_handle,
 	rc = confdb_track_changes(confdb_handle,
 		obj_handle, CONFDB_TRACK_DEPTH_RECURSIVE);
 		obj_handle, CONFDB_TRACK_DEPTH_RECURSIVE);
 	if (rc != CS_OK) {
 	if (rc != CS_OK) {
-		syslog (LOG_ERR,
-			"Failed to track the object. Error %d\n", rc);
+		qb_log(LOG_ERR,
+			"Failed to track the object. Error %d", rc);
 		exit (EXIT_FAILURE);
 		exit (EXIT_FAILURE);
 	}
 	}
 }
 }
@@ -946,33 +946,33 @@ _cs_confdb_finalize(void)
 static void
 static void
 _cs_check_config(void)
 _cs_check_config(void)
 {
 {
-	if (conf[CS_NTF_LOG] == 0 &&
-		conf[CS_NTF_STDOUT] == 0 &&
-		conf[CS_NTF_SNMP] == 0 &&
-		conf[CS_NTF_DBUS] == 0) {
-		syslog(LOG_ERR, "no event type enabled, see corosync-notifyd -h, exiting.");
+	if (conf[CS_NTF_LOG] == QB_FALSE &&
+		conf[CS_NTF_STDOUT] == QB_FALSE &&
+		conf[CS_NTF_SNMP] == QB_FALSE &&
+		conf[CS_NTF_DBUS] == QB_FALSE) {
+		qb_log(LOG_ERR, "no event type enabled, see corosync-notifyd -h, exiting.");
 		exit(EXIT_FAILURE);
 		exit(EXIT_FAILURE);
 	}
 	}
 
 
 #ifndef ENABLE_SNMP
 #ifndef ENABLE_SNMP
 	if (conf[CS_NTF_SNMP]) {
 	if (conf[CS_NTF_SNMP]) {
-		syslog(LOG_ERR, "Not compiled with SNMP support enabled, exiting.");
+		qb_log(LOG_ERR, "Not compiled with SNMP support enabled, exiting.");
 		exit(EXIT_FAILURE);
 		exit(EXIT_FAILURE);
 	}
 	}
 #endif
 #endif
 #ifndef HAVE_DBUS
 #ifndef HAVE_DBUS
 	if (conf[CS_NTF_DBUS]) {
 	if (conf[CS_NTF_DBUS]) {
-		syslog(LOG_ERR, "Not compiled with DBus support enabled, exiting.");
+		qb_log(LOG_ERR, "Not compiled with DBus support enabled, exiting.");
 		exit(EXIT_FAILURE);
 		exit(EXIT_FAILURE);
 	}
 	}
 #endif
 #endif
 
 
 	if (conf[CS_NTF_STDOUT] && !conf[CS_NTF_FG]) {
 	if (conf[CS_NTF_STDOUT] && !conf[CS_NTF_FG]) {
-		syslog(LOG_ERR, "configured to print to stdout and run in the background, exiting");
+		qb_log(LOG_ERR, "configured to print to stdout and run in the background, exiting");
 		exit(EXIT_FAILURE);
 		exit(EXIT_FAILURE);
 	}
 	}
 	if (conf[CS_NTF_SNMP] && conf[CS_NTF_DBUS]) {
 	if (conf[CS_NTF_SNMP] && conf[CS_NTF_DBUS]) {
-		syslog(LOG_ERR, "configured to send snmp traps and dbus signals - are you sure?.");
+		qb_log(LOG_ERR, "configured to send snmp traps and dbus signals - are you sure?.");
 	}
 	}
 }
 }
 
 
@@ -994,35 +994,35 @@ main(int argc, char *argv[])
 {
 {
 	int ch;
 	int ch;
 
 
-	conf[CS_NTF_FG] = 0;
-	conf[CS_NTF_LOG] = 0;
-	conf[CS_NTF_STDOUT] = 0;
-	conf[CS_NTF_SNMP] = 0;
-	conf[CS_NTF_DBUS] = 0;
+	conf[CS_NTF_FG] = QB_FALSE;
+	conf[CS_NTF_LOG] = QB_FALSE;
+	conf[CS_NTF_STDOUT] = QB_FALSE;
+	conf[CS_NTF_SNMP] = QB_FALSE;
+	conf[CS_NTF_DBUS] = QB_FALSE;
 
 
 	while ((ch = getopt (argc, argv, "floshdm:")) != EOF) {
 	while ((ch = getopt (argc, argv, "floshdm:")) != EOF) {
 		switch (ch) {
 		switch (ch) {
 			case 'f':
 			case 'f':
-				conf[CS_NTF_FG] = 1;
+				conf[CS_NTF_FG] = QB_TRUE;
 				break;
 				break;
 			case 'l':
 			case 'l':
-				conf[CS_NTF_LOG] = 1;
+				conf[CS_NTF_LOG] = QB_TRUE;
 				break;
 				break;
 			case 'm':
 			case 'm':
-				conf[CS_NTF_SNMP] = 1;
+				conf[CS_NTF_SNMP] = QB_TRUE;
 				strncpy(snmp_manager_buf, optarg, sizeof (snmp_manager_buf));
 				strncpy(snmp_manager_buf, optarg, sizeof (snmp_manager_buf));
 				snmp_manager_buf[sizeof (snmp_manager_buf) - 1] = '\0';
 				snmp_manager_buf[sizeof (snmp_manager_buf) - 1] = '\0';
 				snmp_manager = snmp_manager_buf;
 				snmp_manager = snmp_manager_buf;
 				break;
 				break;
 			case 'o':
 			case 'o':
-				conf[CS_NTF_LOG] = 1;
-				conf[CS_NTF_STDOUT] = 1;
+				conf[CS_NTF_LOG] = QB_TRUE;
+				conf[CS_NTF_STDOUT] = QB_TRUE;
 				break;
 				break;
 			case 's':
 			case 's':
-				conf[CS_NTF_SNMP] = 1;
+				conf[CS_NTF_SNMP] = QB_TRUE;
 				break;
 				break;
 			case 'd':
 			case 'd':
-				conf[CS_NTF_DBUS] = 1;
+				conf[CS_NTF_DBUS] = QB_TRUE;
 				break;
 				break;
 			case 'h':
 			case 'h':
 			default:
 			default:
@@ -1031,10 +1031,12 @@ main(int argc, char *argv[])
 		}
 		}
 	}
 	}
 
 
+	qb_log_init("notifyd", LOG_DAEMON, LOG_INFO);
+
 	if (conf[CS_NTF_STDOUT]) {
 	if (conf[CS_NTF_STDOUT]) {
-		openlog(NULL, LOG_PID|LOG_PERROR, LOG_DAEMON);
-	} else {
-		openlog(NULL, LOG_PID, LOG_DAEMON);
+		qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD,
+			  QB_LOG_FILTER_FILE, "*", LOG_DEBUG);
+		qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, conf[CS_NTF_STDOUT]);
 	}
 	}
 	_cs_check_config();
 	_cs_check_config();
 
 

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor