cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] Cluster Project branch, master, updated. cluster-2.99.05-9-g95a5c6b
@ 2008-06-25  4:25 fabbione
  2008-06-25 14:43 ` [Cluster-devel] logsys in fenced David Teigland
  0 siblings, 1 reply; 19+ messages in thread
From: fabbione @ 2008-06-25  4:25 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=95a5c6b13294742956b13070ebc4f4513278255f

The branch, master has been updated
       via  95a5c6b13294742956b13070ebc4f4513278255f (commit)
       via  da704715c606c9c01637ae53d79f8dec6a8b0389 (commit)
       via  4906d99305537dd4629b78caf6426c603d2a2e11 (commit)
       via  db2b176d89bcdf549189cdf686dcdffd7793ec98 (commit)
       via  18e085596bb8844f74689a92662f2e5e9166836b (commit)
       via  c54c56c5a09f98547ceda3bc5fa9afa28b354480 (commit)
       via  cf4c7ebac813b0b607acf6cf74bbdddfc8cfb12a (commit)
      from  274ad923e82cf0567e129d1250c7f50ee7ca3b4b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 95a5c6b13294742956b13070ebc4f4513278255f
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
Date:   Wed Jun 25 06:24:11 2008 +0200

    [FENCE] fenced: separate concept of fork and debugging
    
    allow fenced to fork when debugging is set from the configuration
    or the system will hang at boot.
    
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

commit da704715c606c9c01637ae53d79f8dec6a8b0389
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
Date:   Wed Jun 25 05:19:35 2008 +0200

    [FENCE] Allow fenced to configure logsys
    
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

commit 4906d99305537dd4629b78caf6426c603d2a2e11
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
Date:   Wed Jun 25 05:15:55 2008 +0200

    [QDISK] Set debug from syslog_level only when requested
    
    Make also sure to set val to NULL after some operations.
    
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

commit db2b176d89bcdf549189cdf686dcdffd7793ec98
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
Date:   Wed Jun 25 05:15:07 2008 +0200

    [CCS] Set debug from syslog_level only when requested
    
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

commit 18e085596bb8844f74689a92662f2e5e9166836b
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
Date:   Wed Jun 25 04:49:41 2008 +0200

    [FENCE] Move logsys configuration calls where they belong
    
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

commit c54c56c5a09f98547ceda3bc5fa9afa28b354480
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
Date:   Wed Jun 25 04:23:20 2008 +0200

    [FENCE] Make fenced ready to load logsys config
    
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

commit cf4c7ebac813b0b607acf6cf74bbdddfc8cfb12a
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
Date:   Tue Jun 24 14:34:35 2008 +0200

    [FENCE] Start porting fenced to logsys
    
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

-----------------------------------------------------------------------

Summary of changes:
 ccs/daemon/misc.c          |    8 ++-
 cman/qdisk/main.c          |   13 +++-
 fence/fenced/Makefile      |    4 +-
 fence/fenced/config.c      |  147 ++++++++++++++++++++++++++++++++++++++++++--
 fence/fenced/cpg.c         |  116 ++++++++++++++++++-----------------
 fence/fenced/fd.h          |   15 ++---
 fence/fenced/group.c       |   33 +++++-----
 fence/fenced/main.c        |   61 ++++++++++++-------
 fence/fenced/member_cman.c |   19 +++---
 fence/fenced/recover.c     |   26 ++++----
 10 files changed, 304 insertions(+), 138 deletions(-)

diff --git a/ccs/daemon/misc.c b/ccs/daemon/misc.c
index 76f63de..96a7867 100644
--- a/ccs/daemon/misc.c
+++ b/ccs/daemon/misc.c
@@ -200,8 +200,12 @@ int set_ccs_logging(xmlDocPtr ldoc){
       if (loglevel < 0)
 	loglevel = LOG_LEVEL_INFO;
 
-      if(!debug)
+      if(!debug) {
+	if(loglevel == LOG_LEVEL_DEBUG)
+		debug = 1;
+
 	logsys_config_priority_set (loglevel);
+      }
 
       free(res);
       res=NULL;
@@ -276,7 +280,7 @@ int set_ccs_logging(xmlDocPtr ldoc){
   }
 
   if(logmode & LOG_MODE_BUFFER_BEFORE_CONFIG) {
-    log_printf(LOG_DEBUG, "CCS logsys config enabled from set_ccs_logging\n");
+    log_printf(LOG_DEBUG, "logsys config enabled from set_ccs_logging\n");
     logmode &= ~LOG_MODE_BUFFER_BEFORE_CONFIG;
     logmode |= LOG_MODE_FLUSH_AFTER_CONFIG;
     logsys_config_mode_set (logmode);
diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
index 4202508..75ccafe 100644
--- a/cman/qdisk/main.c
+++ b/cman/qdisk/main.c
@@ -1109,11 +1109,14 @@ get_logsys_config_data(int *debug)
 				loglevel = LOG_LEVEL_INFO;
 
 			if (!*debug) {
-				*debug = 1;
+				if (loglevel == LOG_LEVEL_DEBUG)
+					*debug = 1;
+
 				logsys_config_priority_set (loglevel);
 			}
 
 			free(val);
+			val = NULL;
 		} else
 		if (ccs_get(ccsfd, "/cluster/quorumd/@log_level", &val) == 0) { /* check backward compat options */
 			loglevel = logsys_priority_id_get (val);
@@ -1123,11 +1126,14 @@ get_logsys_config_data(int *debug)
 			log_printf(LOG_ERR, "<quorumd log_level=\"%s\".. option is depracated\n", val);
 
 			if (!*debug) {
-				*debug = 1;
+				if (loglevel == LOG_LEVEL_DEBUG)
+					*debug = 1;
+
 				logsys_config_priority_set (loglevel);
 			}
 
 			free(val);
+			val = NULL;
 		}
 	} else
 		logsys_config_priority_set (LOG_LEVEL_DEBUG);
@@ -1197,10 +1203,11 @@ get_logsys_config_data(int *debug)
 
 		logsys_config_facility_set ("QDISK", facility);
 		free(val);
+		val = NULL;
 	}
 
 	if(logmode & LOG_MODE_BUFFER_BEFORE_CONFIG) {
-		log_printf(LOG_DEBUG, "QDISK logsys config enabled from get_logsys_config_data\n");
+		log_printf(LOG_DEBUG, "logsys config enabled from get_logsys_config_data\n");
 		logmode &= ~LOG_MODE_BUFFER_BEFORE_CONFIG;
 		logmode |= LOG_MODE_FLUSH_AFTER_CONFIG;
 		logsys_config_mode_set (logmode);
diff --git a/fence/fenced/Makefile b/fence/fenced/Makefile
index 1e9bbc9..b2b1e04 100644
--- a/fence/fenced/Makefile
+++ b/fence/fenced/Makefile
@@ -22,8 +22,8 @@ CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${fenceincdir} -I${openaisincdir}
 CFLAGS += -I$(S) -I$(S)/../include -I$(S)/../libfenced -I$(SRCDIR)/group/lib
 CFLAGS += -I${incdir}
 
-LDFLAGS += -L${ccslibdir} -L${cmanlibdir} -L${openaislibdir} -lccs -lcman -lcpg
-LDFLAGS += -L${fencelibdir} -L${openaislibdir} -lfence -lcpg -lpthread
+LDFLAGS += -L${ccslibdir} -L${cmanlibdir} -L${openaislibdir} -lccs -lcman -lcpg -llogsys
+LDFLAGS += -L${fencelibdir} -lfence -lpthread
 LDFLAGS += -L../../group/lib -l group
 
 
diff --git a/fence/fenced/config.c b/fence/fenced/config.c
index 56b7b0e..1a038ef 100644
--- a/fence/fenced/config.c
+++ b/fence/fenced/config.c
@@ -1,6 +1,8 @@
 #include "fd.h"
 #include "ccs.h"
 
+LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
+
 static int open_ccs(void)
 {
 	int i = 0, cd;
@@ -8,7 +10,7 @@ static int open_ccs(void)
 	while ((cd = ccs_connect()) < 0) {
 		sleep(1);
 		if (++i > 9 && !(i % 10))
-			log_error("connect to ccs error %d, "
+			log_printf(LOG_ERR, "connect to ccs error %d, "
 				  "check ccsd or cluster status", cd);
 	}
 	return cd;
@@ -27,15 +29,144 @@ static void read_ccs_int(int cd, char *path, int *config_val)
 	val = atoi(str);
 
 	if (val < 0) {
-		log_error("ignore invalid value %d for %s", val, path);
+		log_printf(LOG_ERR, "ignore invalid value %d for %s", val, path);
 		return;
 	}
 
 	*config_val = val;
-	log_debug("%s is %u", path, val);
+	log_printf_debug("%s is %u", path, val);
 	free(str);
 }
 
+int get_logsys_config_data(void)
+{
+	int ccsfd = -1, loglevel = LOG_LEVEL_INFO, facility = SYSLOGFACILITY;
+	char *val = NULL, *error = NULL;
+	unsigned int logmode;
+	int global_debug = 0;
+
+	log_printf(LOG_DEBUG, "Loading logsys configuration information\n");
+
+	ccsfd = ccs_connect();
+	if (ccsfd < 0) {
+		log_printf(LOG_CRIT, "Connection to CCSD failed; cannot start\n");
+		return -1;
+	}
+
+	logmode = logsys_config_mode_get();
+
+	if (!daemon_debug_opt) {
+		if (ccs_get(ccsfd, "/cluster/logging/@debug", &val) == 0) {
+			if(!strcmp(val, "on")) {
+				global_debug = 1;
+			} else
+			if(!strcmp(val, "off")) {
+				global_debug = 0;
+			} else
+				log_printf(LOG_ERR, "global debug: unknown value\n");
+			free(val);
+			val = NULL;
+		}
+
+		if (ccs_get(ccsfd, "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@debug", &val) == 0) {
+			if(!strcmp(val, "on")) {
+				daemon_debug_opt = 1;
+			} else
+			if(!strcmp(val, "off")) { /* debug from cmdline/envvars override config */
+				daemon_debug_opt = 0;
+			} else
+				log_printf(LOG_ERR, "subsys debug: unknown value: %s\n", val);
+			free(val);
+			val = NULL;
+		} else
+			daemon_debug_opt = global_debug; /* global debug overrides subsystem only if latter is not specified */
+
+		if (ccs_get(ccsfd, "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@syslog_level", &val) == 0) {
+			loglevel = logsys_priority_id_get (val);
+			if (loglevel < 0)
+				loglevel = LOG_LEVEL_INFO;
+
+			if (!daemon_debug_opt) {
+				if (loglevel == LOG_LEVEL_DEBUG)
+					daemon_debug_opt = 1;
+
+				logsys_config_priority_set (loglevel);
+			}
+
+			free(val);
+			val = NULL;
+		}
+	} else
+		logsys_config_priority_set (LOG_LEVEL_DEBUG);
+
+	if (ccs_get(ccsfd, "/cluster/logging/@to_stderr", &val) == 0) {
+		if(!strcmp(val, "yes")) {
+			logmode |= LOG_MODE_OUTPUT_STDERR;
+		} else
+		if(!strcmp(val, "no")) {
+			logmode &= ~LOG_MODE_OUTPUT_STDERR;
+		} else
+			log_printf(LOG_ERR, "to_stderr: unknown value\n");
+		free(val);
+		val = NULL;
+	}
+
+	if (ccs_get(ccsfd, "/cluster/logging/@to_syslog", &val) == 0) {
+		if(!strcmp(val, "yes")) {
+			logmode |= LOG_MODE_OUTPUT_SYSLOG_THREADED;
+		} else
+		if(!strcmp(val, "no")) {
+			logmode &= ~LOG_MODE_OUTPUT_SYSLOG_THREADED;
+		} else
+			log_printf(LOG_ERR, "to_syslog: unknown value\n");
+		free(val);
+		val = NULL;
+	}
+
+	if (ccs_get(ccsfd, "/cluster/logging/@to_file", &val) == 0) {
+		if(!strcmp(val, "yes")) {
+			logmode |= LOG_MODE_OUTPUT_FILE;
+		} else
+		if(!strcmp(val, "no")) {
+			logmode &= ~LOG_MODE_OUTPUT_FILE;
+		} else
+			log_printf(LOG_ERR, "to_file: unknown value\n");
+		free(val);
+		val = NULL;
+	}
+
+	if (ccs_get(ccsfd, "/cluster/logging/@filename", &val) == 0) {
+		if(logsys_config_file_set(&error, val))
+			log_printf(LOG_ERR, "filename: unable to open %s for logging\n", val);
+		free(val);
+		val = NULL;
+	} else
+		log_printf(LOG_DEBUG, "filename: use default built-in log file: %s\n", LOGDIR "/fenced.log");
+
+	if (ccs_get(ccsfd, "/cluster/logging/@syslog_facility", &val) == 0) {
+		facility = logsys_facility_id_get (val);
+		if (facility < 0) {
+			log_printf(LOG_ERR, "syslog_facility: unknown value\n");
+			facility = SYSLOGFACILITY;
+		}
+
+		logsys_config_facility_set ("FENCED", facility);
+		free(val);
+		val = NULL;
+	}
+
+	if(logmode & LOG_MODE_BUFFER_BEFORE_CONFIG) {
+		log_printf(LOG_DEBUG, "logsys config enabled from get_logsys_config_data\n");
+		logmode &= ~LOG_MODE_BUFFER_BEFORE_CONFIG;
+		logmode |= LOG_MODE_FLUSH_AFTER_CONFIG;
+		logsys_config_mode_set (logmode);
+	}
+
+	ccs_disconnect(ccsfd);
+
+	return 0;
+}
+
 #define OUR_NAME_PATH "/cluster/clusternodes/clusternode[@name=\"%s\"]/@name"
 #define GROUPD_COMPAT_PATH "/cluster/group/@groupd_compat"
 #define CLEAN_START_PATH "/cluster/fence_daemon/@clean_start"
@@ -50,6 +181,10 @@ int read_ccs(struct fd *fd)
 	char *str;
 	int error, cd, i = 0, count = 0;
 
+	if(trylater)
+		if(get_logsys_config_data())
+			log_printf(LOG_ERR, "Unable to configure logging system\n");
+
 	cd = open_ccs();
 	if (cd < 0)
 		return cd;
@@ -64,7 +199,7 @@ int read_ccs(struct fd *fd)
 
 	error = ccs_get(cd, path, &str);
 	if (error || !str) {
-		log_error("local cman node name \"%s\" not found in the "
+		log_printf(LOG_ERR, "local cman node name \"%s\" not found in the "
 			  "configuration", our_name);
 		return error;
 	}
@@ -102,7 +237,7 @@ int read_ccs(struct fd *fd)
 	}
 
 	if (comline.clean_start) {
-		log_debug("clean start, skipping initial nodes");
+		log_printf_debug("clean start, skipping initial nodes");
 		goto out;
 	}
 
@@ -120,7 +255,7 @@ int read_ccs(struct fd *fd)
 		count++;
 	}
 
-	log_debug("added %d nodes from ccs", count);
+	log_printf_debug("added %d nodes from ccs", count);
  out:
 	ccs_disconnect(cd);
 	return 0;
diff --git a/fence/fenced/cpg.c b/fence/fenced/cpg.c
index c115cc9..3a6b80f 100644
--- a/fence/fenced/cpg.c
+++ b/fence/fenced/cpg.c
@@ -12,6 +12,8 @@ struct member {
 	uint32_t start_flags;
 };
 
+LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
+
 static char *msg_name(int type)
 {
 	switch (type) {
@@ -62,18 +64,18 @@ static int _send_message(cpg_handle_t h, void *buf, int len, int type)
 		retries++;
 		usleep(1000);
 		if (!(retries % 100))
-			log_error("cpg_mcast_joined retry %d %s",
+			log_printf(LOG_ERR, "cpg_mcast_joined retry %d %s",
 				   retries, msg_name(type));
 		goto retry;
 	}
 	if (error != CPG_OK) {
-		log_error("cpg_mcast_joined error %d handle %llx %s",
+		log_printf(LOG_ERR, "cpg_mcast_joined error %d handle %llx %s",
 			  error, (unsigned long long)h, msg_name(type));
 		return -1;
 	}
 
 	if (retries)
-		log_debug("cpg_mcast_joined retried %d %s",
+		log_printf_debug("cpg_mcast_joined retried %d %s",
 			  retries, msg_name(type));
 
 	return 0;
@@ -180,7 +182,7 @@ static void node_history_start(struct fd *fd, int nodeid)
 	
 	node = get_node_history(fd, nodeid);
 	if (!node) {
-		log_error("node_history_start no nodeid %d", nodeid);
+		log_printf(LOG_ERR, "node_history_start no nodeid %d", nodeid);
 		return;
 	}
 
@@ -193,7 +195,7 @@ static void node_history_left(struct fd *fd, int nodeid)
 
 	node = get_node_history(fd, nodeid);
 	if (!node) {
-		log_error("node_history_left no nodeid %d", nodeid);
+		log_printf(LOG_ERR, "node_history_left no nodeid %d", nodeid);
 		return;
 	}
 
@@ -206,7 +208,7 @@ static void node_history_fail(struct fd *fd, int nodeid)
 
 	node = get_node_history(fd, nodeid);
 	if (!node) {
-		log_error("node_history_fail no nodeid %d", nodeid);
+		log_printf(LOG_ERR, "node_history_fail no nodeid %d", nodeid);
 		return;
 	}
 
@@ -225,7 +227,7 @@ void node_history_fence(struct fd *fd, int nodeid, int master, int how)
 
 	node = get_node_history(fd, nodeid);
 	if (!node) {
-		log_error("node_history_fence no nodeid %d", nodeid);
+		log_printf(LOG_ERR, "node_history_fence no nodeid %d", nodeid);
 		return;
 	}
 
@@ -250,7 +252,7 @@ static void node_history_fence_external(struct fd *fd, int nodeid, int from)
 
 	node = get_node_history(fd, nodeid);
 	if (!node) {
-		log_error("node_history_fence_external no nodeid %d", nodeid);
+		log_printf(LOG_ERR, "node_history_fence_external no nodeid %d", nodeid);
 		return;
 	}
 
@@ -278,7 +280,7 @@ void send_external(struct fd *fd, int victim)
 	hd->type = FD_MSG_EXTERNAL;
 	hd->msgdata = victim;
 
-	log_debug("send_external %u", victim);
+	log_printf_debug("send_external %u", victim);
 
 	fd_send_message(fd, buf, len);
 
@@ -292,7 +294,7 @@ void send_external(struct fd *fd, int victim)
 
 static void receive_external(struct fd *fd, struct fd_header *hd, int len)
 {
-	log_debug("receive_external from %d len %d victim %d",
+	log_printf_debug("receive_external from %d len %d victim %d",
 		  hd->nodeid, len, hd->msgdata);
 
 	node_history_fence_external(fd, hd->msgdata, hd->nodeid);
@@ -304,7 +306,7 @@ int is_fenced_external(struct fd *fd, int nodeid)
 
 	node = get_node_history(fd, nodeid);
 	if (!node) {
-		log_error("is_fenced_external no nodeid %d", nodeid);
+		log_printf(LOG_ERR, "is_fenced_external no nodeid %d", nodeid);
 		return 0;
 	}
 
@@ -346,7 +348,7 @@ void send_victim_done(struct fd *fd, int victim, int how)
 	p[1] = cpu_to_le32(how);
 	p[2] = cpu_to_le32(remaining);
 
-	log_debug("send_victim_done %u flags %x victim %d how %d remaining %d",
+	log_printf_debug("send_victim_done %u flags %x victim %d how %d remaining %d",
 		  cg->seq, hd->flags, victim, how, remaining);
 
 	fd_send_message(fd, buf, len);
@@ -361,7 +363,7 @@ static void receive_victim_done(struct fd *fd, struct fd_header *hd, int len)
 	int victim, how, remaining, found;
 	int *nums;
 
-	log_debug("receive_victim_done %d:%u flags %x len %d", hd->nodeid, seq,
+	log_printf_debug("receive_victim_done %d:%u flags %x len %d", hd->nodeid, seq,
 		  hd->flags, len);
 
 	/* check that hd->nodeids is fd->master ? */
@@ -383,7 +385,7 @@ static void receive_victim_done(struct fd *fd, struct fd_header *hd, int len)
 
 	list_for_each_entry(node, &fd->victims, list) {
 		if (node->nodeid == victim) {
-			log_debug("receive_victim_done remove %d how %d rem %d",
+			log_printf_debug("receive_victim_done remove %d how %d rem %d",
 				  victim, how, remaining);
 			node_history_fence(fd, victim, hd->nodeid, how);
 			list_del(&node->list);
@@ -394,7 +396,7 @@ static void receive_victim_done(struct fd *fd, struct fd_header *hd, int len)
 	}
 
 	if (!found)
-		log_debug("receive_victim_done victim %d not found from %d",
+		log_printf_debug("receive_victim_done victim %d not found from %d",
 			  victim, hd->nodeid);
 }
 
@@ -434,7 +436,7 @@ static void send_complete(struct fd *fd)
 	list_for_each_entry(memb, &cg->members, list)
 		p[i++] = cpu_to_le32(memb->nodeid);
 
-	log_debug("send_complete %u counts %d %d %d %d", cg->seq,
+	log_printf_debug("send_complete %u counts %d %d %d %d", cg->seq,
 		  cg->member_count, cg->joined_count,
 		  cg->remove_count, cg->failed_count);
 
@@ -450,7 +452,7 @@ static void receive_complete(struct fd *fd, struct fd_header *hd, int len)
 	uint32_t seq = hd->msgdata;
 	struct node *node, *safe;
 
-	log_debug("receive_complete %d:%u len %d", hd->nodeid, seq, len);
+	log_printf_debug("receive_complete %d:%u len %d", hd->nodeid, seq, len);
 
 	if (fd->init_complete)
 		return;
@@ -464,7 +466,7 @@ static void receive_complete(struct fd *fd, struct fd_header *hd, int len)
 
 	n_ints = 4 + member_count;
 	if (len < (sizeof(struct fd_header) + (n_ints * sizeof(int)))) {
-		log_debug("receive_complete %d:%u bad len %d nums %s",
+		log_printf_debug("receive_complete %d:%u bad len %d nums %s",
 			  hd->nodeid, seq, len, str_nums(nums, n_ints));
 		return;
 	}
@@ -474,7 +476,7 @@ static void receive_complete(struct fd *fd, struct fd_header *hd, int len)
 			break;
 	}
 	if (i == member_count) {
-		log_debug("receive_complete %d:%u we are not in members",
+		log_printf_debug("receive_complete %d:%u we are not in members",
 			  hd->nodeid, seq);
 		return;
 	}
@@ -483,7 +485,7 @@ static void receive_complete(struct fd *fd, struct fd_header *hd, int len)
 
 	/* we may have victims from init which we can clear now */
 	list_for_each_entry_safe(node, safe, &fd->victims, list) {
-		log_debug("receive_complete clear victim %d init %d",
+		log_printf_debug("receive_complete clear victim %d init %d",
 			  node->nodeid, node->init_victim);
 		list_del(&node->list);
 		free(node);
@@ -496,7 +498,7 @@ static int check_quorum_done(struct fd *fd)
 	int wait_count = 0;
 
 	if (!cman_quorate) {
-		log_debug("check_quorum %d", cman_quorate);
+		log_printf_debug("check_quorum %d", cman_quorate);
 		return 0;
 	}
 
@@ -507,7 +509,7 @@ static int check_quorum_done(struct fd *fd)
 		if (!is_cman_member(node->nodeid)) {
 			node->check_quorum = 0;
 		} else {
-			log_debug("check_quorum %d is_cman_member",
+			log_printf_debug("check_quorum %d is_cman_member",
 				  node->nodeid);
 			wait_count++;
 		}
@@ -516,7 +518,7 @@ static int check_quorum_done(struct fd *fd)
 	if (wait_count)
 		return 0;
 
-	log_debug("check_quorum done");
+	log_printf_debug("check_quorum done");
 	return 1;
 }
 
@@ -540,11 +542,11 @@ static int wait_messages_done(struct fd *fd)
 	}
 
 	if (need) {
-		log_debug("wait_messages_done need %d of %d", need, total);
+		log_printf_debug("wait_messages_done need %d of %d", need, total);
 		return 0;
 	}
 
-	log_debug("wait_messages_done got all %d", total);
+	log_printf_debug("wait_messages_done got all %d", total);
 	return 1;
 }
 
@@ -581,7 +583,7 @@ static void set_master(struct fd *fd)
 			complete = memb->nodeid;
 	}
 
-	log_debug("set_master from %d to %s node %d", fd->master,
+	log_printf_debug("set_master from %d to %s node %d", fd->master,
 		  complete ? "complete" : "low",
 		  complete ? complete : low);
 
@@ -607,7 +609,7 @@ static int match_change(struct fd *fd, struct change *cg,
 
 	n_ints = 4 + member_count;
 	if (len < (sizeof(struct fd_header) + (n_ints * sizeof(int)))) {
-		log_debug("match_change fail %d:%u bad len %d nums %s",
+		log_printf_debug("match_change fail %d:%u bad len %d nums %s",
 			  hd->nodeid, seq, len, str_nums(nums, n_ints));
 		return 0;
 	}
@@ -621,14 +623,14 @@ static int match_change(struct fd *fd, struct change *cg,
 			break;
 	}
 	if (i == member_count) {
-		log_debug("match_change fail %d:%u we are not in members",
+		log_printf_debug("match_change fail %d:%u we are not in members",
 			  hd->nodeid, seq);
 		return 0;
 	}
 
 	memb = find_memb(cg, hd->nodeid);
 	if (!memb) {
-		log_debug("match_change fail %d:%u sender not member",
+		log_printf_debug("match_change fail %d:%u sender not member",
 			  hd->nodeid, seq);
 		return 0;
 	}
@@ -640,7 +642,7 @@ static int match_change(struct fd *fd, struct change *cg,
 	    joined_count != cg->joined_count ||
 	    remove_count != cg->remove_count ||
 	    failed_count != cg->failed_count) {
-		log_debug("match_change fail %d:%u expect counts "
+		log_printf_debug("match_change fail %d:%u expect counts "
 			  "%d %d %d %d nums %s",
 			  hd->nodeid, seq,
 			  cg->member_count, cg->joined_count,
@@ -655,7 +657,7 @@ static int match_change(struct fd *fd, struct change *cg,
 		memb = find_memb(cg, nodeid);
 		if (memb)
 			continue;
-		log_debug("match_change fail %d:%u no memb %d",
+		log_printf_debug("match_change fail %d:%u no memb %d",
 			  hd->nodeid, seq, nodeid);
 		members_mismatch = 1;
 	}
@@ -694,7 +696,7 @@ static struct change *find_change(struct fd *fd, struct fd_header *hd, int len)
 		return cg;
 	}
 
-	log_debug("find_change %d:%u no match", hd->nodeid, hd->msgdata);
+	log_printf_debug("find_change %d:%u no match", hd->nodeid, hd->msgdata);
 	return NULL;
 }
 
@@ -715,7 +717,7 @@ static void receive_start(struct fd *fd, struct fd_header *hd, int len)
 	int joining = 0;
 	uint32_t seq = hd->msgdata;
 
-	log_debug("receive_start %d:%u flags %x len %d", hd->nodeid, seq,
+	log_printf_debug("receive_start %d:%u flags %x len %d", hd->nodeid, seq,
 		  hd->flags, len);
 
 	cg = find_change(fd, hd, len);
@@ -725,7 +727,7 @@ static void receive_start(struct fd *fd, struct fd_header *hd, int len)
 	memb = find_memb(cg, hd->nodeid);
 	if (!memb) {
 		/* this should never happen since match_change checks it */
-		log_error("receive_start no member %d", hd->nodeid);
+		log_printf(LOG_ERR, "receive_start no member %d", hd->nodeid);
 		return;
 	}
 
@@ -735,7 +737,7 @@ static void receive_start(struct fd *fd, struct fd_header *hd, int len)
 		joining = 1;
 
 	if ((memb->added && !joining) || (!memb->added && joining)) {
-		log_error("receive_start %d:%u disallowed added %d joining %d",
+		log_printf(LOG_ERR, "receive_start %d:%u disallowed added %d joining %d",
 			  hd->nodeid, seq, memb->added, joining);
 		memb->disallowed = 1;
 	} else {
@@ -785,7 +787,7 @@ static void send_start(struct fd *fd)
 	list_for_each_entry(memb, &cg->members, list)
 		p[i++] = cpu_to_le32(memb->nodeid);
 
-	log_debug("send_start %u flags %x counts %d %d %d %d", cg->seq,
+	log_printf_debug("send_start %u flags %x counts %d %d %d %d", cg->seq,
 		  hd->flags, cg->member_count, cg->joined_count,
 		  cg->remove_count, cg->failed_count);
 
@@ -826,7 +828,7 @@ static void add_victims(struct fd *fd, struct change *cg)
 		if (!node)
 			return;
 		list_add(&node->list, &fd->victims);
-		log_debug("add node %d to victims", node->nodeid);
+		log_printf_debug("add node %d to victims", node->nodeid);
 	}
 }
 
@@ -881,7 +883,7 @@ static void apply_changes(struct fd *fd)
 		break;
 
 	default:
-		log_error("apply_changes invalid state %d", cg->state);
+		log_printf(LOG_ERR, "apply_changes invalid state %d", cg->state);
 	}
 }
 
@@ -945,14 +947,14 @@ static int add_change(struct fd *fd,
 		else
 			node_history_left(fd, memb->nodeid);
 
-		log_debug("add_change %u nodeid %d remove reason %d",
+		log_printf_debug("add_change %u nodeid %d remove reason %d",
 			  cg->seq, memb->nodeid, left_list[i].reason);
 	}
 
 	for (i = 0; i < joined_list_entries; i++) {
 		memb = find_memb(cg, joined_list[i].nodeid);
 		if (!memb) {
-			log_error("no member %d", joined_list[i].nodeid);
+			log_printf(LOG_ERR, "no member %d", joined_list[i].nodeid);
 			error = -ENOENT;
 			goto fail;
 		}
@@ -963,7 +965,7 @@ static int add_change(struct fd *fd,
 		else
 			node_history_init(fd, memb->nodeid);
 
-		log_debug("add_change %u nodeid %d joined", cg->seq,
+		log_printf_debug("add_change %u nodeid %d joined", cg->seq,
 			  memb->nodeid);
 	}
 
@@ -971,7 +973,7 @@ static int add_change(struct fd *fd,
 		list_for_each_entry(memb, &cg->members, list)
 			node_history_init(fd, memb->nodeid);
 
-	log_debug("add_change %u member %d joined %d remove %d failed %d",
+	log_printf_debug("add_change %u member %d joined %d remove %d failed %d",
 		  cg->seq, cg->member_count, cg->joined_count, cg->remove_count,
 		  cg->failed_count);
 
@@ -980,7 +982,7 @@ static int add_change(struct fd *fd,
 	return 0;
 
  fail_nomem:
-	log_error("no memory");
+	log_printf(LOG_ERR, "no memory");
 	error = -ENOMEM;
  fail:
 	free_cg(cg);
@@ -1002,7 +1004,7 @@ static void add_victims_init(struct fd *fd, struct change *cg)
 		    !is_victim(fd, node->nodeid)) {
 			node->init_victim = 1;
 			list_add(&node->list, &fd->victims);
-			log_debug("add_victims_init %d", node->nodeid);
+			log_printf_debug("add_victims_init %d", node->nodeid);
 		} else {
 			free(node);
 		}
@@ -1031,7 +1033,7 @@ static void confchg_cb(cpg_handle_t handle, struct cpg_name *group_name,
 
 	fd = find_fd_handle(handle);
 	if (!fd) {
-		log_error("confchg_cb no fence domain for cpg %s",
+		log_printf(LOG_ERR, "confchg_cb no fence domain for cpg %s",
 			  group_name->value);
 		return;
 	}
@@ -1039,7 +1041,7 @@ static void confchg_cb(cpg_handle_t handle, struct cpg_name *group_name,
 	if (fd->leaving_group && we_left(left_list, left_list_entries)) {
 		/* we called cpg_leave(), and this should be the final
 		   cpg callback we receive */
-		log_debug("confchg for our leave");
+		log_printf_debug("confchg for our leave");
 		cpg_finalize(fd->cpg_handle);
 		client_dead(fd->cpg_client);
 		list_del(&fd->list);
@@ -1074,7 +1076,7 @@ static void deliver_cb(cpg_handle_t handle, struct cpg_name *group_name,
 
 	fd = find_fd_handle(handle);
 	if (!fd) {
-		log_error("deliver_cb no fd for cpg %s", group_name->value);
+		log_printf(LOG_ERR, "deliver_cb no fd for cpg %s", group_name->value);
 		return;
 	}
 
@@ -1091,7 +1093,7 @@ static void deliver_cb(cpg_handle_t handle, struct cpg_name *group_name,
 	hd->msgdata     = le32_to_cpu(hd->msgdata);
 
 	if (hd->version[0] != protocol_active[0]) {
-		log_error("reject message from %d version %u.%u.%u vs %u.%u.%u",
+		log_printf(LOG_ERR, "reject message from %d version %u.%u.%u vs %u.%u.%u",
 			  nodeid, hd->version[0], hd->version[1],
 			  hd->version[2], protocol_active[0],
 			  protocol_active[1], protocol_active[2]);
@@ -1099,7 +1101,7 @@ static void deliver_cb(cpg_handle_t handle, struct cpg_name *group_name,
 	}
 
 	if (hd->nodeid != nodeid) {
-		log_error("bad msg nodeid %d %d", hd->nodeid, nodeid);
+		log_printf(LOG_ERR, "bad msg nodeid %d %d", hd->nodeid, nodeid);
 		return;
 	}
 
@@ -1117,7 +1119,7 @@ static void deliver_cb(cpg_handle_t handle, struct cpg_name *group_name,
 		receive_external(fd, hd, len);
 		break;
 	default:
-		log_error("unknown msg type %d", hd->type);
+		log_printf(LOG_ERR, "unknown msg type %d", hd->type);
 	}
 }
 
@@ -1133,13 +1135,13 @@ static void process_fd_cpg(int ci)
 
 	fd = find_fd_ci(ci);
 	if (!fd) {
-		log_error("process_fd_cpg no fence domain for ci %d", ci);
+		log_printf(LOG_ERR, "process_fd_cpg no fence domain for ci %d", ci);
 		return;
 	}
 
 	error = cpg_dispatch(fd->cpg_handle, CPG_DISPATCH_ALL);
 	if (error != CPG_OK) {
-		log_error("cpg_dispatch error %d", error);
+		log_printf(LOG_ERR, "cpg_dispatch error %d", error);
 		return;
 	}
 
@@ -1155,7 +1157,7 @@ int fd_join(struct fd *fd)
 
 	error = cpg_initialize(&h, &cpg_callbacks);
 	if (error != CPG_OK) {
-		log_error("cpg_initialize error %d", error);
+		log_printf(LOG_ERR, "cpg_initialize error %d", error);
 		goto fail_free;
 	}
 
@@ -1178,11 +1180,11 @@ int fd_join(struct fd *fd)
 	if (error == CPG_ERR_TRY_AGAIN) {
 		sleep(1);
 		if (!(++i % 10))
-			log_error("cpg_join error retrying");
+			log_printf(LOG_ERR, "cpg_join error retrying");
 		goto retry;
 	}
 	if (error != CPG_OK) {
-		log_error("cpg_join error %d", error);
+		log_printf(LOG_ERR, "cpg_join error %d", error);
 		cpg_finalize(h);
 		goto fail;
 	}
@@ -1215,11 +1217,11 @@ int fd_leave(struct fd *fd)
 	if (error == CPG_ERR_TRY_AGAIN) {
 		sleep(1);
 		if (!(++i % 10))
-			log_error("cpg_leave error retrying");
+			log_printf(LOG_ERR, "cpg_leave error retrying");
 		goto retry;
 	}
 	if (error != CPG_OK)
-		log_error("cpg_leave error %d", error);
+		log_printf(LOG_ERR, "cpg_leave error %d", error);
 
 	return 0;
 }
diff --git a/fence/fenced/fd.h b/fence/fenced/fd.h
index 5ef1756..802d29c 100644
--- a/fence/fenced/fd.h
+++ b/fence/fenced/fd.h
@@ -10,7 +10,6 @@
 #include <errno.h>
 #include <string.h>
 #include <stdint.h>
-#include <syslog.h>
 #include <time.h>
 #include <sched.h>
 #include <sys/ioctl.h>
@@ -24,6 +23,7 @@
 
 #include <openais/saAis.h>
 #include <openais/cpg.h>
+#include <openais/service/logsys.h>
 
 #include "list.h"
 #include "linux_endian.h"
@@ -58,6 +58,7 @@
 #define GROUP_LIBCPG            3
 
 extern int daemon_debug_opt;
+extern int daemon_fork;
 extern int daemon_quit;
 extern struct list_head domains;
 extern int cman_quorate;
@@ -68,20 +69,15 @@ extern char dump_buf[FENCED_DUMP_SIZE];
 extern int dump_point;
 extern int dump_wrap;
 extern int group_mode;
+extern int trylater;
 
 extern void daemon_dump_save(void);
 
-#define log_debug(fmt, args...) \
+#define log_printf_debug(fmt, args...) \
 do { \
 	snprintf(daemon_debug_buf, 255, "%ld " fmt "\n", time(NULL), ##args); \
-	if (daemon_debug_opt) fprintf(stderr, "%s", daemon_debug_buf); \
 	daemon_dump_save(); \
-} while (0)
-
-#define log_error(fmt, args...) \
-do { \
-	log_debug(fmt, ##args); \
-	syslog(LOG_ERR, fmt, ##args); \
+	log_printf(LOG_DEBUG, fmt, ##args); \
 } while (0)
 
 /* config option defaults */
@@ -246,6 +242,7 @@ void free_fd(struct fd *fd);
 struct fd *find_fd(char *name);
 void query_lock(void);
 void query_unlock(void);
+int get_logsys_config_data(void);
 
 /* member_cman.c */
 
diff --git a/fence/fenced/group.c b/fence/fenced/group.c
index 5f8f08a..eb43bd5 100644
--- a/fence/fenced/group.c
+++ b/fence/fenced/group.c
@@ -21,6 +21,7 @@ static int cb_type;
 static int cb_member_count;
 static int cb_members[MAX_NODES];
 
+LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
 
 static void stop_cbfn(group_handle_t h, void *private, char *name)
 {
@@ -169,13 +170,13 @@ static void _add_first_victims(struct fd *fd)
 
 	/* complete list initialised in init_nodes() to all nodes from ccs */
 	if (list_empty(&fd->complete))
-		log_debug("first complete list empty warning");
+		log_printf_debug("first complete list empty warning");
 
 	list_for_each_entry_safe(prev_node, safe, &fd->complete, list) {
 		if (!is_cman_member(prev_node->nodeid)) {
 			list_del(&prev_node->list);
 			list_add(&prev_node->list, &fd->victims);
-			log_debug("add first victim %s", prev_node->name);
+			log_printf_debug("add first victim %s", prev_node->name);
 			prev_node->init_victim = 1;
 		}
 	}
@@ -196,7 +197,7 @@ static void _add_victims(struct fd *fd, int start_type, int member_count,
 				list_add(&node->list, &fd->complete);
 			else {
 				list_add(&node->list, &fd->victims);
-				log_debug("add victim %u, was leaving",
+				log_printf_debug("add victim %u, was leaving",
 					  node->nodeid);
 			}
 		}
@@ -206,7 +207,7 @@ static void _add_victims(struct fd *fd, int start_type, int member_count,
 	 * to victims list or leaving list, depending on the type of start. */
 
 	if (list_empty(&fd->complete))
-		log_debug("complete list empty warning");
+		log_printf_debug("complete list empty warning");
 
 	list_for_each_entry_safe(node, safe, &fd->complete, list) {
 		if (!id_in_nodeids(node->nodeid, member_count, nodeids)) {
@@ -217,7 +218,7 @@ static void _add_victims(struct fd *fd, int start_type, int member_count,
 			else
 				list_add(&node->list, &fd->leaving);
 
-			log_debug("add node %u to list %u", node->nodeid,
+			log_printf_debug("add node %u to list %u", node->nodeid,
 				  start_type);
 		}
 	}
@@ -231,7 +232,7 @@ static void add_victims(struct fd *fd, int start_type, int member_count,
 	 * start/stop/start immediately upon joining. */
 
 	if (!fd->last_finish && fd->last_stop) {
-		log_debug("revert aborted first start");
+		log_printf_debug("revert aborted first start");
 		fd->last_stop = 0;
 		fd->first_recovery = 0;
 		free_node_list(&fd->prev);
@@ -239,7 +240,7 @@ static void add_victims(struct fd *fd, int start_type, int member_count,
 		free_node_list(&fd->leaving);
 	}
 
-	log_debug("add_victims stop %d start %d finish %d",
+	log_printf_debug("add_victims stop %d start %d finish %d",
 		  fd->last_stop, fd->last_start, fd->last_finish);
 
 	if (!fd->first_recovery) {
@@ -294,13 +295,13 @@ void process_groupd(int ci)
 
 	switch (cb_action) {
 	case DO_STOP:
-		log_debug("stop %s", cb_name);
+		log_printf_debug("stop %s", cb_name);
 		fd->last_stop = fd->last_start;
 		group_stop_done(gh, cb_name);
 		break;
 
 	case DO_START:
-		log_debug("start %s %d members %s", cb_name, cb_event_nr,
+		log_printf_debug("start %s %d members %s", cb_name, cb_event_nr,
 			  str_members());
 		fd->last_start = cb_event_nr;
 
@@ -320,7 +321,7 @@ void process_groupd(int ci)
 		break;
 
 	case DO_FINISH:
-		log_debug("finish %s %d", cb_name, cb_event_nr);
+		log_printf_debug("finish %s %d", cb_name, cb_event_nr);
 		fd->last_finish = cb_event_nr;
 
 		/* we get terminate callback when all have started, which means
@@ -330,9 +331,9 @@ void process_groupd(int ci)
 		break;
 
 	case DO_TERMINATE:
-		log_debug("terminate %s", cb_name);
+		log_printf_debug("terminate %s", cb_name);
 		if (!fd->leaving_group)
-			log_error("process_groupd terminate not leaving");
+			log_printf(LOG_ERR, "process_groupd terminate not leaving");
 		list_del(&fd->list);
 		free_fd(fd);
 		break;
@@ -354,12 +355,12 @@ int setup_groupd(void)
 
 	gh = group_init(NULL, "fence", 0, &callbacks, GROUPD_TIMEOUT);
 	if (!gh) {
-		log_error("group_init error %p %d", gh, errno);
+		log_printf(LOG_ERR, "group_init error %p %d", gh, errno);
 		return -ENOTCONN;
 	}
 	rv = group_get_fd(gh);
 	if (rv < 0)
-		log_error("group_get_fd error %d %d", rv, errno);
+		log_printf(LOG_ERR, "group_get_fd error %d %d", rv, errno);
 	return rv;
 }
 
@@ -379,7 +380,7 @@ int fd_join_group(struct fd *fd)
 
 	rv = group_join(gh, fd->name);
 	if (rv) {
-		log_error("group_join error %d", rv);
+		log_printf(LOG_ERR, "group_join error %d", rv);
 		list_del(&fd->list);
 		free(fd);
 	}
@@ -394,7 +395,7 @@ int fd_leave_group(struct fd *fd)
 
 	rv = group_leave(gh, fd->name);
 	if (rv)
-		log_error("group_leave error %d", rv);
+		log_printf(LOG_ERR, "group_leave error %d", rv);
 
 	return rv;
 }
diff --git a/fence/fenced/main.c b/fence/fenced/main.c
index 83ca075..7048afa 100644
--- a/fence/fenced/main.c
+++ b/fence/fenced/main.c
@@ -18,6 +18,13 @@ struct client {
 	void *deadfn;
 };
 
+LOGSYS_DECLARE_SYSTEM (NULL,
+	LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_OUTPUT_FILE | LOG_MODE_BUFFER_BEFORE_CONFIG,
+	LOGDIR "/fenced.log",
+	SYSLOGFACILITY);
+
+LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
+
 static int do_read(int fd, void *buf, size_t count)
 {
 	int rv, off = 0;
@@ -68,10 +75,10 @@ static void client_alloc(void)
 		pollfd = realloc(pollfd, (client_size + CLIENT_NALLOC) *
 					 sizeof(struct pollfd));
 		if (!pollfd)
-			log_error("can't alloc for pollfd");
+			log_printf(LOG_ERR, "can't alloc for pollfd");
 	}
 	if (!client || !pollfd)
-		log_error("can't alloc for client array");
+		log_printf(LOG_ERR, "can't alloc for client array");
 
 	for (i = client_size; i < client_size + CLIENT_NALLOC; i++) {
 		client[i].workfn = NULL;
@@ -191,7 +198,7 @@ static int do_join(char *name)
 
 	fd = find_fd(name);
 	if (fd) {
-		log_debug("join error: domain %s exists", name);
+		log_printf_debug("join error: domain %s exists", name);
 		rv = -EEXIST;
 		goto out;
 	}
@@ -406,17 +413,17 @@ static void process_connection(int ci)
 
 	rv = do_read(client[ci].fd, &h, sizeof(h));
 	if (rv < 0) {
-		log_debug("connection %d read error %d", ci, rv);
+		log_printf_debug("connection %d read error %d", ci, rv);
 		goto out;
 	}
 
 	if (h.magic != FENCED_MAGIC) {
-		log_debug("connection %d magic error %x", ci, h.magic);
+		log_printf_debug("connection %d magic error %x", ci, h.magic);
 		goto out;
 	}
 
 	if ((h.version & 0xFFFF0000) != (FENCED_VERSION & 0xFFFF0000)) {
-		log_debug("connection %d version error %x", ci, h.version);
+		log_printf_debug("connection %d version error %x", ci, h.version);
 		goto out;
 	}
 
@@ -424,14 +431,14 @@ static void process_connection(int ci)
 		extra_len = h.len - sizeof(h);
 		extra = malloc(extra_len);
 		if (!extra) {
-			log_error("process_connection no mem %d", extra_len);
+			log_printf(LOG_ERR, "process_connection no mem %d", extra_len);
 			goto out;
 		}
 		memset(extra, 0, extra_len);
 
 		rv = do_read(client[ci].fd, extra, extra_len);
 		if (rv < 0) {
-			log_debug("connection %d extra read error %d", ci, rv);
+			log_printf_debug("connection %d extra read error %d", ci, rv);
 			goto out;
 		}
 	}
@@ -450,10 +457,10 @@ static void process_connection(int ci)
 	case FENCED_CMD_NODE_INFO:
 	case FENCED_CMD_DOMAIN_INFO:
 	case FENCED_CMD_DOMAIN_NODES:
-		log_error("process_connection query on wrong socket");
+		log_printf(LOG_ERR, "process_connection query on wrong socket");
 		break;
 	default:
-		log_error("process_connection %d unknown command %d",
+		log_printf(LOG_ERR, "process_connection %d unknown command %d",
 			  ci, h.command);
 	}
  out:
@@ -468,13 +475,13 @@ static void process_listener(int ci)
 
 	fd = accept(client[ci].fd, NULL, NULL);
 	if (fd < 0) {
-		log_error("process_listener: accept error %d %d", fd, errno);
+		log_printf(LOG_ERR, "process_listener: accept error %d %d", fd, errno);
 		return;
 	}
 	
 	i = client_add(fd, process_connection, NULL);
 
-	log_debug("client connection %d fd %d", i, fd);
+	log_printf_debug("client connection %d fd %d", i, fd);
 }
 
 static int setup_listener(char *sock_path)
@@ -487,7 +494,7 @@ static int setup_listener(char *sock_path)
 
 	s = socket(AF_LOCAL, SOCK_STREAM, 0);
 	if (s < 0) {
-		log_error("socket error %d %d", s, errno);
+		log_printf(LOG_ERR, "socket error %d %d", s, errno);
 		return s;
 	}
 
@@ -498,14 +505,14 @@ static int setup_listener(char *sock_path)
 
 	rv = bind(s, (struct sockaddr *) &addr, addrlen);
 	if (rv < 0) {
-		log_error("bind error %d %d", rv, errno);
+		log_printf(LOG_ERR, "bind error %d %d", rv, errno);
 		close(s);
 		return rv;
 	}
 
 	rv = listen(s, 5);
 	if (rv < 0) {
-		log_error("listen error %d %d", rv, errno);
+		log_printf(LOG_ERR, "listen error %d %d", rv, errno);
 		close(s);
 		return rv;
 	}
@@ -586,7 +593,7 @@ static int setup_queries(void)
 
 	rv = pthread_create(&query_thread, NULL, process_queries, &s);
 	if (rv < 0) {
-		log_error("can't create query thread");
+		log_printf(LOG_ERR, "can't create query thread");
 		close(s);
 		return rv;
 	}
@@ -595,7 +602,7 @@ static int setup_queries(void)
 
 static void cluster_dead(int ci)
 {
-	log_error("cluster is down, exiting");
+	log_printf(LOG_ERR, "cluster is down, exiting");
 	exit(1);
 }
 
@@ -654,7 +661,7 @@ static int loop(void)
 			continue;
 		}
 		if (rv < 0) {
-			log_error("poll errno %d", errno);
+			log_printf(LOG_ERR, "poll errno %d", errno);
 			goto out;
 		}
 
@@ -763,6 +770,7 @@ static void read_arguments(int argc, char **argv)
 
 		case 'D':
 			daemon_debug_opt = 1;
+			daemon_fork = 1;
 			break;
 
 		case 'g':
@@ -854,16 +862,24 @@ int main(int argc, char **argv)
 
 	read_arguments(argc, argv);
 
+	if (daemon_debug_opt)
+		logsys_config_priority_set (LOG_LEVEL_DEBUG);
+
+	trylater = get_logsys_config_data();
+
+	if (trylater)
+		logsys_config_mode_set (LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_OUTPUT_FILE | LOG_MODE_FLUSH_AFTER_CONFIG);
+
 	lockfile();
 
-	if (!daemon_debug_opt) {
+	if (!daemon_fork) {
 		if (daemon(0, 0) < 0) {
-			perror("main: cannot fork");
+			log_printf(LOG_ERR, "main: cannot fork");
 			exit(EXIT_FAILURE);
 		}
 		umask(0);
 	}
-	openlog("fenced", LOG_PID, LOG_DAEMON);
+
 	signal(SIGTERM, sigterm_handler);
 
 	set_oom_adj(-16);
@@ -888,6 +904,7 @@ void daemon_dump_save(void)
 }
 
 int daemon_debug_opt;
+int daemon_fork = 0;
 int daemon_quit;
 struct list_head domains;
 int cman_quorate;
@@ -899,4 +916,4 @@ int dump_point;
 int dump_wrap;
 int group_mode;
 struct commandline comline;
-
+int trylater = 0;
diff --git a/fence/fenced/member_cman.c b/fence/fenced/member_cman.c
index e85fcb6..6ac6e1e 100644
--- a/fence/fenced/member_cman.c
+++ b/fence/fenced/member_cman.c
@@ -7,6 +7,7 @@ static cman_handle_t	ch;
 static cman_node_t	cman_nodes[MAX_NODES];
 static int		cman_node_count;
 
+LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
 
 static int name_equal(char *name1, char *name2)
 {
@@ -99,7 +100,7 @@ static void statechange(void)
 
 	rv = cman_get_nodes(ch, MAX_NODES, &cman_node_count, cman_nodes);
 	if (rv < 0)
-		log_error("cman_get_nodes error %d %d", rv, errno);
+		log_printf(LOG_ERR, "cman_get_nodes error %d %d", rv, errno);
 }
 
 static void cman_callback(cman_handle_t h, void *private, int reason, int arg)
@@ -111,7 +112,7 @@ static void cman_callback(cman_handle_t h, void *private, int reason, int arg)
 		if (list_empty(&domains))
 			cman_replyto_shutdown(ch, 1);
 		else {
-			log_debug("no to cman shutdown");
+			log_printf_debug("no to cman shutdown");
 			cman_replyto_shutdown(ch, 0);
 		}
 		break;
@@ -131,7 +132,7 @@ void process_cman(int ci)
 
 	rv = cman_dispatch(ch, CMAN_DISPATCH_ALL);
 	if (rv == -1 && errno == EHOSTDOWN) {
-		log_error("cluster is down, exiting");
+		log_printf(LOG_ERR, "cluster is down, exiting");
 		exit(1);
 	}
 }
@@ -143,13 +144,13 @@ int setup_cman(void)
 
 	ch = cman_init(NULL);
 	if (!ch) {
-		log_error("cman_init error %p %d", ch, errno);
+		log_printf(LOG_ERR, "cman_init error %p %d", ch, errno);
 		return -ENOTCONN;
 	}
 
 	rv = cman_start_notification(ch, cman_callback);
 	if (rv < 0) {
-		log_error("cman_start_notification error %d %d", rv, errno);
+		log_printf(LOG_ERR, "cman_start_notification error %d %d", rv, errno);
 		cman_finish(ch);
 		return rv;
 	}
@@ -162,7 +163,7 @@ int setup_cman(void)
 	memset(&node, 0, sizeof(node));
 	rv = cman_get_node(ch, CMAN_NODEID_US, &node);
 	if (rv < 0) {
-		log_error("cman_get_node us error %d %d", rv, errno);
+		log_printf(LOG_ERR, "cman_get_node us error %d %d", rv, errno);
 		cman_finish(ch);
 		fd = rv;
 		goto out;
@@ -172,7 +173,7 @@ int setup_cman(void)
 	strncpy(our_name, node.cn_name, CMAN_MAX_NODENAME_LEN);
 	our_nodeid = node.cn_nodeid;
 
-	log_debug("our_nodeid %d our_name %s", our_nodeid, our_name);
+	log_printf_debug("our_nodeid %d our_name %s", our_nodeid, our_name);
  out:
 	return fd;
 }
@@ -196,7 +197,7 @@ int is_cman_member(int nodeid)
 	if (cn && cn->cn_member)
 		return 1;
 
-	log_debug("node %d not a cman member, cn %d", nodeid, cn ? 1 : 0);
+	log_printf_debug("node %d not a cman member, cn %d", nodeid, cn ? 1 : 0);
 	return 0;
 }
 
@@ -216,7 +217,7 @@ struct node *get_new_node(struct fd *fd, int nodeid)
 	memset(&cn, 0, sizeof(cn));
 	rv = cman_get_node(ch, nodeid, &cn);
 	if (rv < 0)
-		log_debug("get_new_node %d no cman node %d", nodeid, rv);
+		log_printf_debug("get_new_node %d no cman node %d", nodeid, rv);
 	else
 		strncpy(node->name, cn.cn_name, MAX_NODENAME_LEN);
 
diff --git a/fence/fenced/recover.c b/fence/fenced/recover.c
index 21bf735..55d1a12 100644
--- a/fence/fenced/recover.c
+++ b/fence/fenced/recover.c
@@ -1,5 +1,7 @@
 #include "fd.h"
 
+LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
+
 void free_node_list(struct list_head *head)
 {
 	struct node *node;
@@ -62,7 +64,7 @@ static int reduce_victims(struct fd *fd)
 
 	list_for_each_entry_safe(node, safe, &fd->victims, list) {
 		if (is_cman_member(node->nodeid)) {
-			log_debug("reduce victim %s", node->name);
+			log_printf_debug("reduce victim %s", node->name);
 			victim_done(fd, node->nodeid, VIC_DONE_MEMBER);
 			list_del(&node->list);
 			free(node);
@@ -116,7 +118,7 @@ static int check_override(int ofd, char *nodename, int timeout)
 
 	ret = select(ofd + 1, &rfds, NULL, NULL, &tv);
 	if (ret < 0) {
-		syslog(LOG_ERR, "select: %s\n", strerror(errno));
+		log_printf(LOG_ERR, "select: %s\n", strerror(errno));
 		return -1;
 	}
 
@@ -126,7 +128,7 @@ static int check_override(int ofd, char *nodename, int timeout)
 	memset(buf, 0, sizeof(buf));
 	ret = read(ofd, buf, sizeof(buf) - 1);
 	if (ret < 0) {
-		syslog(LOG_ERR, "read: %s\n", strerror(errno));
+		log_printf(LOG_ERR, "read: %s\n", strerror(errno));
 		return -1;
 	}
 
@@ -208,11 +210,11 @@ void delay_fencing(struct fd *fd, int node_join)
 
 	gettimeofday(&last, NULL);
 
-	log_debug("delay of %ds leaves %d victims",
+	log_printf_debug("delay of %ds leaves %d victims",
 		  (int) (last.tv_sec - first.tv_sec), victim_count);
  out:
 	list_for_each_entry(node, &fd->victims, list) {
-		syslog(LOG_INFO, "%s not a cluster member after %d sec %s",
+		log_printf(LOG_INFO, "%s not a cluster member after %d sec %s",
 		       node->name, delay, delay_type);
 	}
 }
@@ -226,8 +228,8 @@ void defer_fencing(struct fd *fd)
 
 	master_name = nodeid_to_name(fd->master);
 
-	log_debug("defer fencing to %d %s", fd->master, master_name);
-	syslog(LOG_INFO, "fencing deferred to %s", master_name);
+	log_printf_debug("defer fencing to %d %s", fd->master, master_name);
+	log_printf(LOG_INFO, "fencing deferred to %s", master_name);
 }
 
 void fence_victims(struct fd *fd)
@@ -247,7 +249,7 @@ void fence_victims(struct fd *fd)
 			fenced = 0;
 
 		if (member || fenced) {
-			log_debug("averting fence of node %s "
+			log_printf_debug("averting fence of node %s "
 				  "member %d external %d",
 				  node->name, member, fenced);
 			victim_done(fd, node->nodeid, member ? VIC_DONE_MEMBER :
@@ -257,14 +259,14 @@ void fence_victims(struct fd *fd)
 			continue;
 		}
 
-		log_debug("fencing node %s", node->name);
-		syslog(LOG_INFO, "fencing node \"%s\"", node->name);
+		log_printf_debug("fencing node %s", node->name);
+		log_printf(LOG_INFO, "fencing node \"%s\"", node->name);
 
 		query_unlock();
 		error = fence_node(node->name);
 		query_lock();
 
-		syslog(LOG_INFO, "fence \"%s\" %s", node->name,
+		log_printf(LOG_INFO, "fence \"%s\" %s", node->name,
 		       error ? "failed" : "success");
 
 		if (!error) {
@@ -286,7 +288,7 @@ void fence_victims(struct fd *fd)
 		override = open_override(comline.override_path);
 		if (check_override(override, node->name,
 				   comline.override_time) > 0) {
-			syslog(LOG_WARNING, "fence \"%s\" overridden by "
+			log_printf(LOG_WARNING, "fence \"%s\" overridden by "
 			       "administrator intervention", node->name);
 			victim_done(fd, node->nodeid, VIC_DONE_OVERRIDE);
 			list_del(&node->list);


hooks/post-receive
--
Cluster Project



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-25  4:25 [Cluster-devel] Cluster Project branch, master, updated. cluster-2.99.05-9-g95a5c6b fabbione
@ 2008-06-25 14:43 ` David Teigland
  2008-06-25 14:53   ` Christine Caulfield
                     ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: David Teigland @ 2008-06-25 14:43 UTC (permalink / raw)
  To: cluster-devel.redhat.com

> commit 95a5c6b13294742956b13070ebc4f4513278255f
> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
> Date:   Wed Jun 25 06:24:11 2008 +0200
> 
>     [FENCE] fenced: separate concept of fork and debugging
>     
>     allow fenced to fork when debugging is set from the configuration
>     or the system will hang at boot.
>     
>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
> 
> commit da704715c606c9c01637ae53d79f8dec6a8b0389
> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
> Date:   Wed Jun 25 05:19:35 2008 +0200
> 
>     [FENCE] Allow fenced to configure logsys
>     
>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
> 
> commit 18e085596bb8844f74689a92662f2e5e9166836b
> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
> Date:   Wed Jun 25 04:49:41 2008 +0200
> 
>     [FENCE] Move logsys configuration calls where they belong
>     
>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
> 
> commit c54c56c5a09f98547ceda3bc5fa9afa28b354480
> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
> Date:   Wed Jun 25 04:23:20 2008 +0200
> 
>     [FENCE] Make fenced ready to load logsys config
>     
>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
> 
> commit cf4c7ebac813b0b607acf6cf74bbdddfc8cfb12a
> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
> Date:   Tue Jun 24 14:34:35 2008 +0200
> 
>     [FENCE] Start porting fenced to logsys
>     
>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

OK, I'm fine with replacing the use of syslog with logsys, but this goes
beyond that.  Here are the problems I see:


. Leave log_debug() unchanged, and leave the meaning/effect of -D unchanged.
  syslog/logsys are about logging to files.  The debug "logging" I use is
  about logging to either an in-memory buffer or to stderr; syslog/logsys
  are not relevant to that.


. Change log_error() to use logsys instead of syslog, i.e. don't change
  the existing log_error() call sites.

  #define log_error(fmt, args...) \
  do { \
	log_debug(fmt, ##args); \
  -	syslog(LOG_ERR, fmt, ##args); \
  + 	log_printf(LOG_ERR, fmt, ##args); \
  } while (0)


. Finally, one gripe with logsys itself.  Here's syslog initialization:

  openlog("fenced", LOG_PID, LOG_DAEMON);

  Compare with logsys initialization:

  LOGSYS_DECLARE_SYSTEM (NULL,
  	LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | 
	LOG_MODE_OUTPUT_FILE | LOG_MODE_BUFFER_BEFORE_CONFIG,
	LOGDIR "/fenced.log",
	SYSLOGFACILITY);
  LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);

  ...

  logsys_config_mode_set(LOG_MODE_OUTPUT_STDERR |
	LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_OUTPUT_FILE | 
	LOG_MODE_FLUSH_AFTER_CONFIG);

  ... and at the start of every other file:

  LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);

  This really gets out of hand.  I'd like to see the initialization wrapped
  into a single function call, and the macros at the start of every file
  unnecessary.
 



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-25 14:43 ` [Cluster-devel] logsys in fenced David Teigland
@ 2008-06-25 14:53   ` Christine Caulfield
  2008-06-25 15:55     ` David Teigland
  2008-06-25 16:12   ` Steven Dake
  2008-06-25 16:19   ` Fabio M. Di Nitto
  2 siblings, 1 reply; 19+ messages in thread
From: Christine Caulfield @ 2008-06-25 14:53 UTC (permalink / raw)
  To: cluster-devel.redhat.com

David Teigland wrote:
>> commit 95a5c6b13294742956b13070ebc4f4513278255f
>> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
>> Date:   Wed Jun 25 06:24:11 2008 +0200
>>
>>     [FENCE] fenced: separate concept of fork and debugging
>>     
>>     allow fenced to fork when debugging is set from the configuration
>>     or the system will hang at boot.
>>     
>>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
>>
>> commit da704715c606c9c01637ae53d79f8dec6a8b0389
>> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
>> Date:   Wed Jun 25 05:19:35 2008 +0200
>>
>>     [FENCE] Allow fenced to configure logsys
>>     
>>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
>>
>> commit 18e085596bb8844f74689a92662f2e5e9166836b
>> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
>> Date:   Wed Jun 25 04:49:41 2008 +0200
>>
>>     [FENCE] Move logsys configuration calls where they belong
>>     
>>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
>>
>> commit c54c56c5a09f98547ceda3bc5fa9afa28b354480
>> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
>> Date:   Wed Jun 25 04:23:20 2008 +0200
>>
>>     [FENCE] Make fenced ready to load logsys config
>>     
>>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
>>
>> commit cf4c7ebac813b0b607acf6cf74bbdddfc8cfb12a
>> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
>> Date:   Tue Jun 24 14:34:35 2008 +0200
>>
>>     [FENCE] Start porting fenced to logsys
>>     
>>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
> 
> OK, I'm fine with replacing the use of syslog with logsys, but this goes
> beyond that.  Here are the problems I see:
> 
> 
> . Leave log_debug() unchanged, and leave the meaning/effect of -D unchanged.
>   syslog/logsys are about logging to files.  The debug "logging" I use is
>   about logging to either an in-memory buffer or to stderr; syslog/logsys
>   are not relevant to that.

But isn't the point of logsys to centralise all our logging so the user 
can say whether it goes to stderr, a file or syslog. and that it all 
uses the same code so it's easy to tell users how to redirect it as they 
want.

Having a few exceptions that always log to stderr is just confusing and 
defeats the point of having a common system.

> 
> . Change log_error() to use logsys instead of syslog, i.e. don't change
>   the existing log_error() call sites.
> 
>   #define log_error(fmt, args...) \
>   do { \
> 	log_debug(fmt, ##args); \
>   -	syslog(LOG_ERR, fmt, ##args); \
>   + 	log_printf(LOG_ERR, fmt, ##args); \
>   } while (0)

So then we have a do {} while macro whose only purpose is to simply 
change the name of a function call. Now THAT's surely ugly and pointless.

-- 

Chrissie



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-25 14:53   ` Christine Caulfield
@ 2008-06-25 15:55     ` David Teigland
  0 siblings, 0 replies; 19+ messages in thread
From: David Teigland @ 2008-06-25 15:55 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Wed, Jun 25, 2008 at 03:53:58PM +0100, Christine Caulfield wrote:
> >. Leave log_debug() unchanged, and leave the meaning/effect of -D 
> >unchanged.
> >  syslog/logsys are about logging to files.  The debug "logging" I use is
> >  about logging to either an in-memory buffer or to stderr; syslog/logsys
> >  are not relevant to that.
> 
> But isn't the point of logsys to centralise all our logging so the user 
> can say whether it goes to stderr, a file or syslog. and that it all 
> uses the same code so it's easy to tell users how to redirect it as they 
> want.

To a file or syslog yes.  Re stderr, I don't think you understand how the
stderr output is used.  When you run "fenced -D", the daemon is run in the
foreground and all debug output goes to stderr.  foreground and
debug-to-stderr always go together, and it's always an inherently manual
process, always done explicitly from the command line, always done on the
individual programs you want to observe.  This is the *manual debugging
process* we're talking about here.

> >. Change log_error() to use logsys instead of syslog, i.e. don't change
> >  the existing log_error() call sites.
> >
> >  #define log_error(fmt, args...) \
> >  do { \
> >	log_debug(fmt, ##args); \
> >  -	syslog(LOG_ERR, fmt, ##args); \
> >  + 	log_printf(LOG_ERR, fmt, ##args); \
> >  } while (0)
> 
> So then we have a do {} while macro whose only purpose is to simply 
> change the name of a function call. Now THAT's surely ugly and pointless.

No, I count four separate things the log_error macro does (including the
name change).



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-25 14:43 ` [Cluster-devel] logsys in fenced David Teigland
  2008-06-25 14:53   ` Christine Caulfield
@ 2008-06-25 16:12   ` Steven Dake
  2008-06-25 16:19   ` Fabio M. Di Nitto
  2 siblings, 0 replies; 19+ messages in thread
From: Steven Dake @ 2008-06-25 16:12 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Wed, 2008-06-25 at 09:43 -0500, David Teigland wrote:
> > commit 95a5c6b13294742956b13070ebc4f4513278255f
> > Author: Fabio M. Di Nitto <fdinitto@redhat.com>
> > Date:   Wed Jun 25 06:24:11 2008 +0200
> > 
> >     [FENCE] fenced: separate concept of fork and debugging
> >     
> >     allow fenced to fork when debugging is set from the configuration
> >     or the system will hang at boot.
> >     
> >     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
> > 
> > commit da704715c606c9c01637ae53d79f8dec6a8b0389
> > Author: Fabio M. Di Nitto <fdinitto@redhat.com>
> > Date:   Wed Jun 25 05:19:35 2008 +0200
> > 
> >     [FENCE] Allow fenced to configure logsys
> >     
> >     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
> > 
> > commit 18e085596bb8844f74689a92662f2e5e9166836b
> > Author: Fabio M. Di Nitto <fdinitto@redhat.com>
> > Date:   Wed Jun 25 04:49:41 2008 +0200
> > 
> >     [FENCE] Move logsys configuration calls where they belong
> >     
> >     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
> > 
> > commit c54c56c5a09f98547ceda3bc5fa9afa28b354480
> > Author: Fabio M. Di Nitto <fdinitto@redhat.com>
> > Date:   Wed Jun 25 04:23:20 2008 +0200
> > 
> >     [FENCE] Make fenced ready to load logsys config
> >     
> >     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
> > 
> > commit cf4c7ebac813b0b607acf6cf74bbdddfc8cfb12a
> > Author: Fabio M. Di Nitto <fdinitto@redhat.com>
> > Date:   Tue Jun 24 14:34:35 2008 +0200
> > 
> >     [FENCE] Start porting fenced to logsys
> >     
> >     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
> 
> OK, I'm fine with replacing the use of syslog with logsys, but this goes
> beyond that.  Here are the problems I see:
> 
> 
> . Leave log_debug() unchanged, and leave the meaning/effect of -D unchanged.
>   syslog/logsys are about logging to files.  The debug "logging" I use is
>   about logging to either an in-memory buffer or to stderr; syslog/logsys
>   are not relevant to that.
> 
> 
> . Change log_error() to use logsys instead of syslog, i.e. don't change
>   the existing log_error() call sites.
> 
>   #define log_error(fmt, args...) \
>   do { \
> 	log_debug(fmt, ##args); \
>   -	syslog(LOG_ERR, fmt, ##args); \
>   + 	log_printf(LOG_ERR, fmt, ##args); \
>   } while (0)
> 
> 
> . Finally, one gripe with logsys itself.  Here's syslog initialization:
> 
>   openlog("fenced", LOG_PID, LOG_DAEMON);
> 
>   Compare with logsys initialization:
> 
>   LOGSYS_DECLARE_SYSTEM (NULL,
>   	LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | 
> 	LOG_MODE_OUTPUT_FILE | LOG_MODE_BUFFER_BEFORE_CONFIG,
> 	LOGDIR "/fenced.log",
> 	SYSLOGFACILITY);
>   LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
> 
>   ...
> 
>   logsys_config_mode_set(LOG_MODE_OUTPUT_STDERR |
> 	LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_OUTPUT_FILE | 
> 	LOG_MODE_FLUSH_AFTER_CONFIG);
> 

The declaration of the logging system is up to individual choice.  If we
were to make it one macro "LOGSYS_DECLARE_SYSTEM()" without any
arguments, the user of logsys would have no choice.  While openlog may
be simple, it also offers very little functionality.  It simply "opens a
log".  It doesn't let you declare whether you want to output to stderr,
or also if you want threaded mode of operation, or whether you should
wait for fork to execute your first logging output.  Because it doesn't
support these features, it can be a simple little api "start logging to
file X".  Logsys offers a variety of features and isn't simply an api to
log to syslog, but a full blown logging system to support a variety of
goals all with nonblocking operation.

I suggest reading the man page to understand what each of those options
mean.  I think once you do, you will see that none of them can be
removed, and there is no way to have an "openlog" api that also supports
the features of logsys. 

>   ... and at the start of every other file:
> 
>   LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
> 
>   This really gets out of hand.  I'd like to see the initialization wrapped
>   into a single function call, and the macros at the start of every file
>   unnecessary.
>  
> 

The necessity for the DECLARE_SUBSYS macro is to support subsystems.
Looking at the macro we see how this is implemented:

#define LOGSYS_DECLARE_SUBSYS(subsys,priority)                          \
static unsigned int logsys_subsys_id __attribute__((unused));           \
__attribute__ ((constructor)) static void logsys_subsys_init (void)     \
{                                                                       \
        logsys_subsys_id =                                              \
                _logsys_subsys_create ((subsys), (priority));           \
}

So what exactly does this macro do?  It creates a local static variable that any logging
function can use to tell the logsys system which subsystem it belongs to.  This is absolutely
required.  The _logsys_subsys_create maps a character string to this 32 bit identifier.

There is no other way to support subsystem logging in a particular file.  The reason is
log_printf needs to know which subsystem it should log under for the particular invocation.
This is done via the logsys_subsys_id static variable in each file.

If you can propose an alternative that would do exactly the same thing, I'm all ears.

I really don't see the big issue with adding one line of code to each
file to support subsystem logging.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-25 14:43 ` [Cluster-devel] logsys in fenced David Teigland
  2008-06-25 14:53   ` Christine Caulfield
  2008-06-25 16:12   ` Steven Dake
@ 2008-06-25 16:19   ` Fabio M. Di Nitto
  2008-06-25 16:50     ` David Teigland
  2 siblings, 1 reply; 19+ messages in thread
From: Fabio M. Di Nitto @ 2008-06-25 16:19 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Wed, 25 Jun 2008, David Teigland wrote:

>> commit 95a5c6b13294742956b13070ebc4f4513278255f
>> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
>> Date:   Wed Jun 25 06:24:11 2008 +0200
>>
>>     [FENCE] fenced: separate concept of fork and debugging
>>
>>     allow fenced to fork when debugging is set from the configuration
>>     or the system will hang at boot.
>>
>>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
>>
>> commit da704715c606c9c01637ae53d79f8dec6a8b0389
>> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
>> Date:   Wed Jun 25 05:19:35 2008 +0200
>>
>>     [FENCE] Allow fenced to configure logsys
>>
>>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
>>
>> commit 18e085596bb8844f74689a92662f2e5e9166836b
>> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
>> Date:   Wed Jun 25 04:49:41 2008 +0200
>>
>>     [FENCE] Move logsys configuration calls where they belong
>>
>>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
>>
>> commit c54c56c5a09f98547ceda3bc5fa9afa28b354480
>> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
>> Date:   Wed Jun 25 04:23:20 2008 +0200
>>
>>     [FENCE] Make fenced ready to load logsys config
>>
>>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
>>
>> commit cf4c7ebac813b0b607acf6cf74bbdddfc8cfb12a
>> Author: Fabio M. Di Nitto <fdinitto@redhat.com>
>> Date:   Tue Jun 24 14:34:35 2008 +0200
>>
>>     [FENCE] Start porting fenced to logsys
>>
>>     Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
>
> OK, I'm fine with replacing the use of syslog with logsys, but this goes
> beyond that.  Here are the problems I see:
>
>
> . Leave log_debug() unchanged,

The only change is that it uses logsys to print instead fprintf to stderr. 
Like Christine already pointed out, the change to logsys is to have log 
output the same across the whole system. No exceptions. Debug is no 
different from that, and with logsys you can set debug logs at runtime 
instead of having to do manual things.

> and leave the meaning/effect of -D unchanged.

This is unchanged. Read carefully what I did. By setting debug_daemon_opt 
to 1, (also set by debug=on config option) you can theoretically halt the 
machine boot (if you need to debug that early in the process).

Invoking with -D will also avoid forking of the daemon (fork_daemon_opt or 
whatever i called it).

Original behaviour preserverd. Add more flexibility to debug.

>  syslog/logsys are about logging to files.

this is an assumption. logsys allows you to log to file, syslog and stderr 
according to what you need.

>  The debug "logging" I use is
>  about logging to either an in-memory buffer or to stderr; syslog/logsys
>  are not relevant to that.

What is wrong with collecting debugging info in a standard way?

>
>
> . Change log_error() to use logsys instead of syslog, i.e. don't change
>  the existing log_error() call sites.
>
>  #define log_error(fmt, args...) \
>  do { \
> 	log_debug(fmt, ##args); \
>  -	syslog(LOG_ERR, fmt, ##args); \
>  + 	log_printf(LOG_ERR, fmt, ##args); \
>  } while (0)

and what's the gain to keep around a macro that does nothing vs calling 
directly log_printf?

>
>
> . Finally, one gripe with logsys itself.  Here's syslog initialization:
>

Discuss this with Steven.

Fabio

--
I'm going to make him an offer he can't refuse.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-25 16:19   ` Fabio M. Di Nitto
@ 2008-06-25 16:50     ` David Teigland
  2008-06-25 17:04       ` Fabio M. Di Nitto
  0 siblings, 1 reply; 19+ messages in thread
From: David Teigland @ 2008-06-25 16:50 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Wed, Jun 25, 2008 at 06:19:00PM +0200, Fabio M. Di Nitto wrote:
> >. Leave log_debug() unchanged,
> 
> The only change is that it uses logsys to print instead fprintf to stderr. 
> Like Christine already pointed out, the change to logsys is to have log 
> output the same across the whole system. No exceptions. Debug is no 
> different from that,

I'm saying it is different.  My debugging capabilities are completely
separate from logging.  You're trying to redefine them for me, and I'm
declining.

> and with logsys you can set debug logs at runtime 
> instead of having to do manual things.

Sorry, that's not what I want.

> > syslog/logsys are about logging to files.
> 
> this is an assumption. logsys allows you to log to file, syslog and stderr 
> according to what you need.

That's fine for the log_error statements, not for debugging statements.

> What is wrong with collecting debugging info in a standard way?

For now, my only interest in logsys is as a replacement for syslog.  Once
that works, I'll consider changes to the debug system.

> and what's the gain to keep around a macro that does nothing vs calling 
> directly log_printf?

See my other mail, and you're venturing into coding style preferences that
are not relevant to logsys.

> >. Finally, one gripe with logsys itself.  Here's syslog initialization:
> >
> 
> Discuss this with Steven.

Yes, I'll be studying the gory logsys details in an effort to propose some
more concrete api suggestions.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-25 16:50     ` David Teigland
@ 2008-06-25 17:04       ` Fabio M. Di Nitto
  2008-06-25 17:30         ` David Teigland
  0 siblings, 1 reply; 19+ messages in thread
From: Fabio M. Di Nitto @ 2008-06-25 17:04 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Wed, 25 Jun 2008, David Teigland wrote:

> On Wed, Jun 25, 2008 at 06:19:00PM +0200, Fabio M. Di Nitto wrote:
>>> . Leave log_debug() unchanged,
>>
>> The only change is that it uses logsys to print instead fprintf to stderr.
>> Like Christine already pointed out, the change to logsys is to have log
>> output the same across the whole system. No exceptions. Debug is no
>> different from that,
>
> I'm saying it is different.  My debugging capabilities are completely
> separate from logging.  You're trying to redefine them for me, and I'm
> declining.
>
>> and with logsys you can set debug logs at runtime
>> instead of having to do manual things.
>
> Sorry, that's not what I want.

Our stack is absolutely impossible to debug as it is. There is a different 
debugging method and system for every single piece of code in the stack.
It is a nightmare for people that wants to gather debugging output for us 
and send us logs.

Your way:

- learn every single debugging options for every single subsystem and 
command and maybe you will be able to find the data we need to help you 
because they are spreaded across logging files, syslogs and maybe stderr.

My way:

- add debug=on on the logging system. tar /var/log/cluster. done.

While I respect that your idea of debugging is different, can you at least 
see the benefits for a one line change in a macro?

>>> syslog/logsys are about logging to files.
>>
>> this is an assumption. logsys allows you to log to file, syslog and stderr
>> according to what you need.
>
> That's fine for the log_error statements, not for debugging statements.
>
>> What is wrong with collecting debugging info in a standard way?
>
> For now, my only interest in logsys is as a replacement for syslog.  Once
> that works, I'll consider changes to the debug system.

It works already. We have been fixing bugs in logsys at a constant rate 
before starting the transition.

Fabio

--
I'm going to make him an offer he can't refuse.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-25 17:04       ` Fabio M. Di Nitto
@ 2008-06-25 17:30         ` David Teigland
  0 siblings, 0 replies; 19+ messages in thread
From: David Teigland @ 2008-06-25 17:30 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Wed, Jun 25, 2008 at 07:04:15PM +0200, Fabio M. Di Nitto wrote:
> Our stack is absolutely impossible to debug as it is. There is a different 
> debugging method and system for every single piece of code in the stack.
> It is a nightmare for people that wants to gather debugging output for us 
> and send us logs.
> 
> Your way:
> 
> - learn every single debugging options for every single subsystem and 
> command and maybe you will be able to find the data we need to help you 
> because they are spreaded across logging files, syslogs and maybe stderr.
> 
> My way:
> 
> - add debug=on on the logging system. tar /var/log/cluster. done.
> 
> While I respect that your idea of debugging is different, can you at least 
> see the benefits for a one line change in a macro?

OK, once log_debug is back to the way it was, then I'll look into how to
direct debug statements to logsys in a way that's acceptable to me.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
@ 2008-06-25 21:21 David Teigland
  2008-06-26  3:48 ` Fabio M. Di Nitto
  2008-06-26 21:43 ` David Teigland
  0 siblings, 2 replies; 19+ messages in thread
From: David Teigland @ 2008-06-25 21:21 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Attached two patches:
  fenced-revert.patch reverts the current logsys changes to fenced.
  fenced-logsys.patch is my own logsys conversion for fenced.

I've not compiled or tested these patches yet (the version of openais I
have working on my test machines does not have logsys and I don't want to
disrupt my tests on those machines.)  I'll push these once they compile.

I have yet to study logsys enough to propose an alternative to the macro
magic that's now isolated at the end of fd.h.

Regarding libfence which uses syslog, we can just remove the syslog calls,
they're nonessential.  I guess fence agents should log errors, if they
don't already.

-------------- next part --------------
>From: David Teigland <teigland@redhat.com>
>Date: Wed, 25 Jun 2008 13:30:11 -0500
>Subject: fenced: revert logsys commits

[FENCE] Start porting fenced to logsys
cf4c7ebac813b0b607acf6cf74bbdddfc8cfb12a

[FENCE] Make fenced ready to load logsys config
c54c56c5a09f98547ceda3bc5fa9afa28b354480

[FENCE] Move logsys configuration calls where they belong
18e085596bb8844f74689a92662f2e5e9166836b

[FENCE] Allow fenced to configure logsys
da704715c606c9c01637ae53d79f8dec6a8b0389

[FENCE] fenced: separate concept of fork and debugging
95a5c6b13294742956b13070ebc4f4513278255f
---
 fence/fenced/Makefile      |    4 +-
 fence/fenced/config.c      |  147 ++------------------------------------------
 fence/fenced/cpg.c         |  116 +++++++++++++++++------------------
 fence/fenced/fd.h          |   15 +++--
 fence/fenced/group.c       |   33 +++++-----
 fence/fenced/main.c        |   61 +++++++------------
 fence/fenced/member_cman.c |   19 +++---
 fence/fenced/recover.c     |   26 ++++----
 8 files changed, 133 insertions(+), 288 deletions(-)

diff --git a/fence/fenced/Makefile b/fence/fenced/Makefile
index b2b1e04..1e9bbc9 100644
--- a/fence/fenced/Makefile
+++ b/fence/fenced/Makefile
@@ -22,8 +22,8 @@ CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${fenceincdir} -I${openaisincdir}
 CFLAGS += -I$(S) -I$(S)/../include -I$(S)/../libfenced -I$(SRCDIR)/group/lib
 CFLAGS += -I${incdir}
 
-LDFLAGS += -L${ccslibdir} -L${cmanlibdir} -L${openaislibdir} -lccs -lcman -lcpg -llogsys
-LDFLAGS += -L${fencelibdir} -lfence -lpthread
+LDFLAGS += -L${ccslibdir} -L${cmanlibdir} -L${openaislibdir} -lccs -lcman -lcpg
+LDFLAGS += -L${fencelibdir} -L${openaislibdir} -lfence -lcpg -lpthread
 LDFLAGS += -L../../group/lib -l group
 
 
diff --git a/fence/fenced/config.c b/fence/fenced/config.c
index 1a038ef..56b7b0e 100644
--- a/fence/fenced/config.c
+++ b/fence/fenced/config.c
@@ -1,8 +1,6 @@
 #include "fd.h"
 #include "ccs.h"
 
-LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
-
 static int open_ccs(void)
 {
 	int i = 0, cd;
@@ -10,7 +8,7 @@ static int open_ccs(void)
 	while ((cd = ccs_connect()) < 0) {
 		sleep(1);
 		if (++i > 9 && !(i % 10))
-			log_printf(LOG_ERR, "connect to ccs error %d, "
+			log_error("connect to ccs error %d, "
 				  "check ccsd or cluster status", cd);
 	}
 	return cd;
@@ -29,144 +27,15 @@ static void read_ccs_int(int cd, char *path, int *config_val)
 	val = atoi(str);
 
 	if (val < 0) {
-		log_printf(LOG_ERR, "ignore invalid value %d for %s", val, path);
+		log_error("ignore invalid value %d for %s", val, path);
 		return;
 	}
 
 	*config_val = val;
-	log_printf_debug("%s is %u", path, val);
+	log_debug("%s is %u", path, val);
 	free(str);
 }
 
-int get_logsys_config_data(void)
-{
-	int ccsfd = -1, loglevel = LOG_LEVEL_INFO, facility = SYSLOGFACILITY;
-	char *val = NULL, *error = NULL;
-	unsigned int logmode;
-	int global_debug = 0;
-
-	log_printf(LOG_DEBUG, "Loading logsys configuration information\n");
-
-	ccsfd = ccs_connect();
-	if (ccsfd < 0) {
-		log_printf(LOG_CRIT, "Connection to CCSD failed; cannot start\n");
-		return -1;
-	}
-
-	logmode = logsys_config_mode_get();
-
-	if (!daemon_debug_opt) {
-		if (ccs_get(ccsfd, "/cluster/logging/@debug", &val) == 0) {
-			if(!strcmp(val, "on")) {
-				global_debug = 1;
-			} else
-			if(!strcmp(val, "off")) {
-				global_debug = 0;
-			} else
-				log_printf(LOG_ERR, "global debug: unknown value\n");
-			free(val);
-			val = NULL;
-		}
-
-		if (ccs_get(ccsfd, "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@debug", &val) == 0) {
-			if(!strcmp(val, "on")) {
-				daemon_debug_opt = 1;
-			} else
-			if(!strcmp(val, "off")) { /* debug from cmdline/envvars override config */
-				daemon_debug_opt = 0;
-			} else
-				log_printf(LOG_ERR, "subsys debug: unknown value: %s\n", val);
-			free(val);
-			val = NULL;
-		} else
-			daemon_debug_opt = global_debug; /* global debug overrides subsystem only if latter is not specified */
-
-		if (ccs_get(ccsfd, "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@syslog_level", &val) == 0) {
-			loglevel = logsys_priority_id_get (val);
-			if (loglevel < 0)
-				loglevel = LOG_LEVEL_INFO;
-
-			if (!daemon_debug_opt) {
-				if (loglevel == LOG_LEVEL_DEBUG)
-					daemon_debug_opt = 1;
-
-				logsys_config_priority_set (loglevel);
-			}
-
-			free(val);
-			val = NULL;
-		}
-	} else
-		logsys_config_priority_set (LOG_LEVEL_DEBUG);
-
-	if (ccs_get(ccsfd, "/cluster/logging/@to_stderr", &val) == 0) {
-		if(!strcmp(val, "yes")) {
-			logmode |= LOG_MODE_OUTPUT_STDERR;
-		} else
-		if(!strcmp(val, "no")) {
-			logmode &= ~LOG_MODE_OUTPUT_STDERR;
-		} else
-			log_printf(LOG_ERR, "to_stderr: unknown value\n");
-		free(val);
-		val = NULL;
-	}
-
-	if (ccs_get(ccsfd, "/cluster/logging/@to_syslog", &val) == 0) {
-		if(!strcmp(val, "yes")) {
-			logmode |= LOG_MODE_OUTPUT_SYSLOG_THREADED;
-		} else
-		if(!strcmp(val, "no")) {
-			logmode &= ~LOG_MODE_OUTPUT_SYSLOG_THREADED;
-		} else
-			log_printf(LOG_ERR, "to_syslog: unknown value\n");
-		free(val);
-		val = NULL;
-	}
-
-	if (ccs_get(ccsfd, "/cluster/logging/@to_file", &val) == 0) {
-		if(!strcmp(val, "yes")) {
-			logmode |= LOG_MODE_OUTPUT_FILE;
-		} else
-		if(!strcmp(val, "no")) {
-			logmode &= ~LOG_MODE_OUTPUT_FILE;
-		} else
-			log_printf(LOG_ERR, "to_file: unknown value\n");
-		free(val);
-		val = NULL;
-	}
-
-	if (ccs_get(ccsfd, "/cluster/logging/@filename", &val) == 0) {
-		if(logsys_config_file_set(&error, val))
-			log_printf(LOG_ERR, "filename: unable to open %s for logging\n", val);
-		free(val);
-		val = NULL;
-	} else
-		log_printf(LOG_DEBUG, "filename: use default built-in log file: %s\n", LOGDIR "/fenced.log");
-
-	if (ccs_get(ccsfd, "/cluster/logging/@syslog_facility", &val) == 0) {
-		facility = logsys_facility_id_get (val);
-		if (facility < 0) {
-			log_printf(LOG_ERR, "syslog_facility: unknown value\n");
-			facility = SYSLOGFACILITY;
-		}
-
-		logsys_config_facility_set ("FENCED", facility);
-		free(val);
-		val = NULL;
-	}
-
-	if(logmode & LOG_MODE_BUFFER_BEFORE_CONFIG) {
-		log_printf(LOG_DEBUG, "logsys config enabled from get_logsys_config_data\n");
-		logmode &= ~LOG_MODE_BUFFER_BEFORE_CONFIG;
-		logmode |= LOG_MODE_FLUSH_AFTER_CONFIG;
-		logsys_config_mode_set (logmode);
-	}
-
-	ccs_disconnect(ccsfd);
-
-	return 0;
-}
-
 #define OUR_NAME_PATH "/cluster/clusternodes/clusternode[@name=\"%s\"]/@name"
 #define GROUPD_COMPAT_PATH "/cluster/group/@groupd_compat"
 #define CLEAN_START_PATH "/cluster/fence_daemon/@clean_start"
@@ -181,10 +50,6 @@ int read_ccs(struct fd *fd)
 	char *str;
 	int error, cd, i = 0, count = 0;
 
-	if(trylater)
-		if(get_logsys_config_data())
-			log_printf(LOG_ERR, "Unable to configure logging system\n");
-
 	cd = open_ccs();
 	if (cd < 0)
 		return cd;
@@ -199,7 +64,7 @@ int read_ccs(struct fd *fd)
 
 	error = ccs_get(cd, path, &str);
 	if (error || !str) {
-		log_printf(LOG_ERR, "local cman node name \"%s\" not found in the "
+		log_error("local cman node name \"%s\" not found in the "
 			  "configuration", our_name);
 		return error;
 	}
@@ -237,7 +102,7 @@ int read_ccs(struct fd *fd)
 	}
 
 	if (comline.clean_start) {
-		log_printf_debug("clean start, skipping initial nodes");
+		log_debug("clean start, skipping initial nodes");
 		goto out;
 	}
 
@@ -255,7 +120,7 @@ int read_ccs(struct fd *fd)
 		count++;
 	}
 
-	log_printf_debug("added %d nodes from ccs", count);
+	log_debug("added %d nodes from ccs", count);
  out:
 	ccs_disconnect(cd);
 	return 0;
diff --git a/fence/fenced/cpg.c b/fence/fenced/cpg.c
index 3a6b80f..c115cc9 100644
--- a/fence/fenced/cpg.c
+++ b/fence/fenced/cpg.c
@@ -12,8 +12,6 @@ struct member {
 	uint32_t start_flags;
 };
 
-LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
-
 static char *msg_name(int type)
 {
 	switch (type) {
@@ -64,18 +62,18 @@ static int _send_message(cpg_handle_t h, void *buf, int len, int type)
 		retries++;
 		usleep(1000);
 		if (!(retries % 100))
-			log_printf(LOG_ERR, "cpg_mcast_joined retry %d %s",
+			log_error("cpg_mcast_joined retry %d %s",
 				   retries, msg_name(type));
 		goto retry;
 	}
 	if (error != CPG_OK) {
-		log_printf(LOG_ERR, "cpg_mcast_joined error %d handle %llx %s",
+		log_error("cpg_mcast_joined error %d handle %llx %s",
 			  error, (unsigned long long)h, msg_name(type));
 		return -1;
 	}
 
 	if (retries)
-		log_printf_debug("cpg_mcast_joined retried %d %s",
+		log_debug("cpg_mcast_joined retried %d %s",
 			  retries, msg_name(type));
 
 	return 0;
@@ -182,7 +180,7 @@ static void node_history_start(struct fd *fd, int nodeid)
 	
 	node = get_node_history(fd, nodeid);
 	if (!node) {
-		log_printf(LOG_ERR, "node_history_start no nodeid %d", nodeid);
+		log_error("node_history_start no nodeid %d", nodeid);
 		return;
 	}
 
@@ -195,7 +193,7 @@ static void node_history_left(struct fd *fd, int nodeid)
 
 	node = get_node_history(fd, nodeid);
 	if (!node) {
-		log_printf(LOG_ERR, "node_history_left no nodeid %d", nodeid);
+		log_error("node_history_left no nodeid %d", nodeid);
 		return;
 	}
 
@@ -208,7 +206,7 @@ static void node_history_fail(struct fd *fd, int nodeid)
 
 	node = get_node_history(fd, nodeid);
 	if (!node) {
-		log_printf(LOG_ERR, "node_history_fail no nodeid %d", nodeid);
+		log_error("node_history_fail no nodeid %d", nodeid);
 		return;
 	}
 
@@ -227,7 +225,7 @@ void node_history_fence(struct fd *fd, int nodeid, int master, int how)
 
 	node = get_node_history(fd, nodeid);
 	if (!node) {
-		log_printf(LOG_ERR, "node_history_fence no nodeid %d", nodeid);
+		log_error("node_history_fence no nodeid %d", nodeid);
 		return;
 	}
 
@@ -252,7 +250,7 @@ static void node_history_fence_external(struct fd *fd, int nodeid, int from)
 
 	node = get_node_history(fd, nodeid);
 	if (!node) {
-		log_printf(LOG_ERR, "node_history_fence_external no nodeid %d", nodeid);
+		log_error("node_history_fence_external no nodeid %d", nodeid);
 		return;
 	}
 
@@ -280,7 +278,7 @@ void send_external(struct fd *fd, int victim)
 	hd->type = FD_MSG_EXTERNAL;
 	hd->msgdata = victim;
 
-	log_printf_debug("send_external %u", victim);
+	log_debug("send_external %u", victim);
 
 	fd_send_message(fd, buf, len);
 
@@ -294,7 +292,7 @@ void send_external(struct fd *fd, int victim)
 
 static void receive_external(struct fd *fd, struct fd_header *hd, int len)
 {
-	log_printf_debug("receive_external from %d len %d victim %d",
+	log_debug("receive_external from %d len %d victim %d",
 		  hd->nodeid, len, hd->msgdata);
 
 	node_history_fence_external(fd, hd->msgdata, hd->nodeid);
@@ -306,7 +304,7 @@ int is_fenced_external(struct fd *fd, int nodeid)
 
 	node = get_node_history(fd, nodeid);
 	if (!node) {
-		log_printf(LOG_ERR, "is_fenced_external no nodeid %d", nodeid);
+		log_error("is_fenced_external no nodeid %d", nodeid);
 		return 0;
 	}
 
@@ -348,7 +346,7 @@ void send_victim_done(struct fd *fd, int victim, int how)
 	p[1] = cpu_to_le32(how);
 	p[2] = cpu_to_le32(remaining);
 
-	log_printf_debug("send_victim_done %u flags %x victim %d how %d remaining %d",
+	log_debug("send_victim_done %u flags %x victim %d how %d remaining %d",
 		  cg->seq, hd->flags, victim, how, remaining);
 
 	fd_send_message(fd, buf, len);
@@ -363,7 +361,7 @@ static void receive_victim_done(struct fd *fd, struct fd_header *hd, int len)
 	int victim, how, remaining, found;
 	int *nums;
 
-	log_printf_debug("receive_victim_done %d:%u flags %x len %d", hd->nodeid, seq,
+	log_debug("receive_victim_done %d:%u flags %x len %d", hd->nodeid, seq,
 		  hd->flags, len);
 
 	/* check that hd->nodeids is fd->master ? */
@@ -385,7 +383,7 @@ static void receive_victim_done(struct fd *fd, struct fd_header *hd, int len)
 
 	list_for_each_entry(node, &fd->victims, list) {
 		if (node->nodeid == victim) {
-			log_printf_debug("receive_victim_done remove %d how %d rem %d",
+			log_debug("receive_victim_done remove %d how %d rem %d",
 				  victim, how, remaining);
 			node_history_fence(fd, victim, hd->nodeid, how);
 			list_del(&node->list);
@@ -396,7 +394,7 @@ static void receive_victim_done(struct fd *fd, struct fd_header *hd, int len)
 	}
 
 	if (!found)
-		log_printf_debug("receive_victim_done victim %d not found from %d",
+		log_debug("receive_victim_done victim %d not found from %d",
 			  victim, hd->nodeid);
 }
 
@@ -436,7 +434,7 @@ static void send_complete(struct fd *fd)
 	list_for_each_entry(memb, &cg->members, list)
 		p[i++] = cpu_to_le32(memb->nodeid);
 
-	log_printf_debug("send_complete %u counts %d %d %d %d", cg->seq,
+	log_debug("send_complete %u counts %d %d %d %d", cg->seq,
 		  cg->member_count, cg->joined_count,
 		  cg->remove_count, cg->failed_count);
 
@@ -452,7 +450,7 @@ static void receive_complete(struct fd *fd, struct fd_header *hd, int len)
 	uint32_t seq = hd->msgdata;
 	struct node *node, *safe;
 
-	log_printf_debug("receive_complete %d:%u len %d", hd->nodeid, seq, len);
+	log_debug("receive_complete %d:%u len %d", hd->nodeid, seq, len);
 
 	if (fd->init_complete)
 		return;
@@ -466,7 +464,7 @@ static void receive_complete(struct fd *fd, struct fd_header *hd, int len)
 
 	n_ints = 4 + member_count;
 	if (len < (sizeof(struct fd_header) + (n_ints * sizeof(int)))) {
-		log_printf_debug("receive_complete %d:%u bad len %d nums %s",
+		log_debug("receive_complete %d:%u bad len %d nums %s",
 			  hd->nodeid, seq, len, str_nums(nums, n_ints));
 		return;
 	}
@@ -476,7 +474,7 @@ static void receive_complete(struct fd *fd, struct fd_header *hd, int len)
 			break;
 	}
 	if (i == member_count) {
-		log_printf_debug("receive_complete %d:%u we are not in members",
+		log_debug("receive_complete %d:%u we are not in members",
 			  hd->nodeid, seq);
 		return;
 	}
@@ -485,7 +483,7 @@ static void receive_complete(struct fd *fd, struct fd_header *hd, int len)
 
 	/* we may have victims from init which we can clear now */
 	list_for_each_entry_safe(node, safe, &fd->victims, list) {
-		log_printf_debug("receive_complete clear victim %d init %d",
+		log_debug("receive_complete clear victim %d init %d",
 			  node->nodeid, node->init_victim);
 		list_del(&node->list);
 		free(node);
@@ -498,7 +496,7 @@ static int check_quorum_done(struct fd *fd)
 	int wait_count = 0;
 
 	if (!cman_quorate) {
-		log_printf_debug("check_quorum %d", cman_quorate);
+		log_debug("check_quorum %d", cman_quorate);
 		return 0;
 	}
 
@@ -509,7 +507,7 @@ static int check_quorum_done(struct fd *fd)
 		if (!is_cman_member(node->nodeid)) {
 			node->check_quorum = 0;
 		} else {
-			log_printf_debug("check_quorum %d is_cman_member",
+			log_debug("check_quorum %d is_cman_member",
 				  node->nodeid);
 			wait_count++;
 		}
@@ -518,7 +516,7 @@ static int check_quorum_done(struct fd *fd)
 	if (wait_count)
 		return 0;
 
-	log_printf_debug("check_quorum done");
+	log_debug("check_quorum done");
 	return 1;
 }
 
@@ -542,11 +540,11 @@ static int wait_messages_done(struct fd *fd)
 	}
 
 	if (need) {
-		log_printf_debug("wait_messages_done need %d of %d", need, total);
+		log_debug("wait_messages_done need %d of %d", need, total);
 		return 0;
 	}
 
-	log_printf_debug("wait_messages_done got all %d", total);
+	log_debug("wait_messages_done got all %d", total);
 	return 1;
 }
 
@@ -583,7 +581,7 @@ static void set_master(struct fd *fd)
 			complete = memb->nodeid;
 	}
 
-	log_printf_debug("set_master from %d to %s node %d", fd->master,
+	log_debug("set_master from %d to %s node %d", fd->master,
 		  complete ? "complete" : "low",
 		  complete ? complete : low);
 
@@ -609,7 +607,7 @@ static int match_change(struct fd *fd, struct change *cg,
 
 	n_ints = 4 + member_count;
 	if (len < (sizeof(struct fd_header) + (n_ints * sizeof(int)))) {
-		log_printf_debug("match_change fail %d:%u bad len %d nums %s",
+		log_debug("match_change fail %d:%u bad len %d nums %s",
 			  hd->nodeid, seq, len, str_nums(nums, n_ints));
 		return 0;
 	}
@@ -623,14 +621,14 @@ static int match_change(struct fd *fd, struct change *cg,
 			break;
 	}
 	if (i == member_count) {
-		log_printf_debug("match_change fail %d:%u we are not in members",
+		log_debug("match_change fail %d:%u we are not in members",
 			  hd->nodeid, seq);
 		return 0;
 	}
 
 	memb = find_memb(cg, hd->nodeid);
 	if (!memb) {
-		log_printf_debug("match_change fail %d:%u sender not member",
+		log_debug("match_change fail %d:%u sender not member",
 			  hd->nodeid, seq);
 		return 0;
 	}
@@ -642,7 +640,7 @@ static int match_change(struct fd *fd, struct change *cg,
 	    joined_count != cg->joined_count ||
 	    remove_count != cg->remove_count ||
 	    failed_count != cg->failed_count) {
-		log_printf_debug("match_change fail %d:%u expect counts "
+		log_debug("match_change fail %d:%u expect counts "
 			  "%d %d %d %d nums %s",
 			  hd->nodeid, seq,
 			  cg->member_count, cg->joined_count,
@@ -657,7 +655,7 @@ static int match_change(struct fd *fd, struct change *cg,
 		memb = find_memb(cg, nodeid);
 		if (memb)
 			continue;
-		log_printf_debug("match_change fail %d:%u no memb %d",
+		log_debug("match_change fail %d:%u no memb %d",
 			  hd->nodeid, seq, nodeid);
 		members_mismatch = 1;
 	}
@@ -696,7 +694,7 @@ static struct change *find_change(struct fd *fd, struct fd_header *hd, int len)
 		return cg;
 	}
 
-	log_printf_debug("find_change %d:%u no match", hd->nodeid, hd->msgdata);
+	log_debug("find_change %d:%u no match", hd->nodeid, hd->msgdata);
 	return NULL;
 }
 
@@ -717,7 +715,7 @@ static void receive_start(struct fd *fd, struct fd_header *hd, int len)
 	int joining = 0;
 	uint32_t seq = hd->msgdata;
 
-	log_printf_debug("receive_start %d:%u flags %x len %d", hd->nodeid, seq,
+	log_debug("receive_start %d:%u flags %x len %d", hd->nodeid, seq,
 		  hd->flags, len);
 
 	cg = find_change(fd, hd, len);
@@ -727,7 +725,7 @@ static void receive_start(struct fd *fd, struct fd_header *hd, int len)
 	memb = find_memb(cg, hd->nodeid);
 	if (!memb) {
 		/* this should never happen since match_change checks it */
-		log_printf(LOG_ERR, "receive_start no member %d", hd->nodeid);
+		log_error("receive_start no member %d", hd->nodeid);
 		return;
 	}
 
@@ -737,7 +735,7 @@ static void receive_start(struct fd *fd, struct fd_header *hd, int len)
 		joining = 1;
 
 	if ((memb->added && !joining) || (!memb->added && joining)) {
-		log_printf(LOG_ERR, "receive_start %d:%u disallowed added %d joining %d",
+		log_error("receive_start %d:%u disallowed added %d joining %d",
 			  hd->nodeid, seq, memb->added, joining);
 		memb->disallowed = 1;
 	} else {
@@ -787,7 +785,7 @@ static void send_start(struct fd *fd)
 	list_for_each_entry(memb, &cg->members, list)
 		p[i++] = cpu_to_le32(memb->nodeid);
 
-	log_printf_debug("send_start %u flags %x counts %d %d %d %d", cg->seq,
+	log_debug("send_start %u flags %x counts %d %d %d %d", cg->seq,
 		  hd->flags, cg->member_count, cg->joined_count,
 		  cg->remove_count, cg->failed_count);
 
@@ -828,7 +826,7 @@ static void add_victims(struct fd *fd, struct change *cg)
 		if (!node)
 			return;
 		list_add(&node->list, &fd->victims);
-		log_printf_debug("add node %d to victims", node->nodeid);
+		log_debug("add node %d to victims", node->nodeid);
 	}
 }
 
@@ -883,7 +881,7 @@ static void apply_changes(struct fd *fd)
 		break;
 
 	default:
-		log_printf(LOG_ERR, "apply_changes invalid state %d", cg->state);
+		log_error("apply_changes invalid state %d", cg->state);
 	}
 }
 
@@ -947,14 +945,14 @@ static int add_change(struct fd *fd,
 		else
 			node_history_left(fd, memb->nodeid);
 
-		log_printf_debug("add_change %u nodeid %d remove reason %d",
+		log_debug("add_change %u nodeid %d remove reason %d",
 			  cg->seq, memb->nodeid, left_list[i].reason);
 	}
 
 	for (i = 0; i < joined_list_entries; i++) {
 		memb = find_memb(cg, joined_list[i].nodeid);
 		if (!memb) {
-			log_printf(LOG_ERR, "no member %d", joined_list[i].nodeid);
+			log_error("no member %d", joined_list[i].nodeid);
 			error = -ENOENT;
 			goto fail;
 		}
@@ -965,7 +963,7 @@ static int add_change(struct fd *fd,
 		else
 			node_history_init(fd, memb->nodeid);
 
-		log_printf_debug("add_change %u nodeid %d joined", cg->seq,
+		log_debug("add_change %u nodeid %d joined", cg->seq,
 			  memb->nodeid);
 	}
 
@@ -973,7 +971,7 @@ static int add_change(struct fd *fd,
 		list_for_each_entry(memb, &cg->members, list)
 			node_history_init(fd, memb->nodeid);
 
-	log_printf_debug("add_change %u member %d joined %d remove %d failed %d",
+	log_debug("add_change %u member %d joined %d remove %d failed %d",
 		  cg->seq, cg->member_count, cg->joined_count, cg->remove_count,
 		  cg->failed_count);
 
@@ -982,7 +980,7 @@ static int add_change(struct fd *fd,
 	return 0;
 
  fail_nomem:
-	log_printf(LOG_ERR, "no memory");
+	log_error("no memory");
 	error = -ENOMEM;
  fail:
 	free_cg(cg);
@@ -1004,7 +1002,7 @@ static void add_victims_init(struct fd *fd, struct change *cg)
 		    !is_victim(fd, node->nodeid)) {
 			node->init_victim = 1;
 			list_add(&node->list, &fd->victims);
-			log_printf_debug("add_victims_init %d", node->nodeid);
+			log_debug("add_victims_init %d", node->nodeid);
 		} else {
 			free(node);
 		}
@@ -1033,7 +1031,7 @@ static void confchg_cb(cpg_handle_t handle, struct cpg_name *group_name,
 
 	fd = find_fd_handle(handle);
 	if (!fd) {
-		log_printf(LOG_ERR, "confchg_cb no fence domain for cpg %s",
+		log_error("confchg_cb no fence domain for cpg %s",
 			  group_name->value);
 		return;
 	}
@@ -1041,7 +1039,7 @@ static void confchg_cb(cpg_handle_t handle, struct cpg_name *group_name,
 	if (fd->leaving_group && we_left(left_list, left_list_entries)) {
 		/* we called cpg_leave(), and this should be the final
 		   cpg callback we receive */
-		log_printf_debug("confchg for our leave");
+		log_debug("confchg for our leave");
 		cpg_finalize(fd->cpg_handle);
 		client_dead(fd->cpg_client);
 		list_del(&fd->list);
@@ -1076,7 +1074,7 @@ static void deliver_cb(cpg_handle_t handle, struct cpg_name *group_name,
 
 	fd = find_fd_handle(handle);
 	if (!fd) {
-		log_printf(LOG_ERR, "deliver_cb no fd for cpg %s", group_name->value);
+		log_error("deliver_cb no fd for cpg %s", group_name->value);
 		return;
 	}
 
@@ -1093,7 +1091,7 @@ static void deliver_cb(cpg_handle_t handle, struct cpg_name *group_name,
 	hd->msgdata     = le32_to_cpu(hd->msgdata);
 
 	if (hd->version[0] != protocol_active[0]) {
-		log_printf(LOG_ERR, "reject message from %d version %u.%u.%u vs %u.%u.%u",
+		log_error("reject message from %d version %u.%u.%u vs %u.%u.%u",
 			  nodeid, hd->version[0], hd->version[1],
 			  hd->version[2], protocol_active[0],
 			  protocol_active[1], protocol_active[2]);
@@ -1101,7 +1099,7 @@ static void deliver_cb(cpg_handle_t handle, struct cpg_name *group_name,
 	}
 
 	if (hd->nodeid != nodeid) {
-		log_printf(LOG_ERR, "bad msg nodeid %d %d", hd->nodeid, nodeid);
+		log_error("bad msg nodeid %d %d", hd->nodeid, nodeid);
 		return;
 	}
 
@@ -1119,7 +1117,7 @@ static void deliver_cb(cpg_handle_t handle, struct cpg_name *group_name,
 		receive_external(fd, hd, len);
 		break;
 	default:
-		log_printf(LOG_ERR, "unknown msg type %d", hd->type);
+		log_error("unknown msg type %d", hd->type);
 	}
 }
 
@@ -1135,13 +1133,13 @@ static void process_fd_cpg(int ci)
 
 	fd = find_fd_ci(ci);
 	if (!fd) {
-		log_printf(LOG_ERR, "process_fd_cpg no fence domain for ci %d", ci);
+		log_error("process_fd_cpg no fence domain for ci %d", ci);
 		return;
 	}
 
 	error = cpg_dispatch(fd->cpg_handle, CPG_DISPATCH_ALL);
 	if (error != CPG_OK) {
-		log_printf(LOG_ERR, "cpg_dispatch error %d", error);
+		log_error("cpg_dispatch error %d", error);
 		return;
 	}
 
@@ -1157,7 +1155,7 @@ int fd_join(struct fd *fd)
 
 	error = cpg_initialize(&h, &cpg_callbacks);
 	if (error != CPG_OK) {
-		log_printf(LOG_ERR, "cpg_initialize error %d", error);
+		log_error("cpg_initialize error %d", error);
 		goto fail_free;
 	}
 
@@ -1180,11 +1178,11 @@ int fd_join(struct fd *fd)
 	if (error == CPG_ERR_TRY_AGAIN) {
 		sleep(1);
 		if (!(++i % 10))
-			log_printf(LOG_ERR, "cpg_join error retrying");
+			log_error("cpg_join error retrying");
 		goto retry;
 	}
 	if (error != CPG_OK) {
-		log_printf(LOG_ERR, "cpg_join error %d", error);
+		log_error("cpg_join error %d", error);
 		cpg_finalize(h);
 		goto fail;
 	}
@@ -1217,11 +1215,11 @@ int fd_leave(struct fd *fd)
 	if (error == CPG_ERR_TRY_AGAIN) {
 		sleep(1);
 		if (!(++i % 10))
-			log_printf(LOG_ERR, "cpg_leave error retrying");
+			log_error("cpg_leave error retrying");
 		goto retry;
 	}
 	if (error != CPG_OK)
-		log_printf(LOG_ERR, "cpg_leave error %d", error);
+		log_error("cpg_leave error %d", error);
 
 	return 0;
 }
diff --git a/fence/fenced/fd.h b/fence/fenced/fd.h
index 802d29c..5ef1756 100644
--- a/fence/fenced/fd.h
+++ b/fence/fenced/fd.h
@@ -10,6 +10,7 @@
 #include <errno.h>
 #include <string.h>
 #include <stdint.h>
+#include <syslog.h>
 #include <time.h>
 #include <sched.h>
 #include <sys/ioctl.h>
@@ -23,7 +24,6 @@
 
 #include <openais/saAis.h>
 #include <openais/cpg.h>
-#include <openais/service/logsys.h>
 
 #include "list.h"
 #include "linux_endian.h"
@@ -58,7 +58,6 @@
 #define GROUP_LIBCPG            3
 
 extern int daemon_debug_opt;
-extern int daemon_fork;
 extern int daemon_quit;
 extern struct list_head domains;
 extern int cman_quorate;
@@ -69,15 +68,20 @@ extern char dump_buf[FENCED_DUMP_SIZE];
 extern int dump_point;
 extern int dump_wrap;
 extern int group_mode;
-extern int trylater;
 
 extern void daemon_dump_save(void);
 
-#define log_printf_debug(fmt, args...) \
+#define log_debug(fmt, args...) \
 do { \
 	snprintf(daemon_debug_buf, 255, "%ld " fmt "\n", time(NULL), ##args); \
+	if (daemon_debug_opt) fprintf(stderr, "%s", daemon_debug_buf); \
 	daemon_dump_save(); \
-	log_printf(LOG_DEBUG, fmt, ##args); \
+} while (0)
+
+#define log_error(fmt, args...) \
+do { \
+	log_debug(fmt, ##args); \
+	syslog(LOG_ERR, fmt, ##args); \
 } while (0)
 
 /* config option defaults */
@@ -242,7 +246,6 @@ void free_fd(struct fd *fd);
 struct fd *find_fd(char *name);
 void query_lock(void);
 void query_unlock(void);
-int get_logsys_config_data(void);
 
 /* member_cman.c */
 
diff --git a/fence/fenced/group.c b/fence/fenced/group.c
index eb43bd5..5f8f08a 100644
--- a/fence/fenced/group.c
+++ b/fence/fenced/group.c
@@ -21,7 +21,6 @@ static int cb_type;
 static int cb_member_count;
 static int cb_members[MAX_NODES];
 
-LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
 
 static void stop_cbfn(group_handle_t h, void *private, char *name)
 {
@@ -170,13 +169,13 @@ static void _add_first_victims(struct fd *fd)
 
 	/* complete list initialised in init_nodes() to all nodes from ccs */
 	if (list_empty(&fd->complete))
-		log_printf_debug("first complete list empty warning");
+		log_debug("first complete list empty warning");
 
 	list_for_each_entry_safe(prev_node, safe, &fd->complete, list) {
 		if (!is_cman_member(prev_node->nodeid)) {
 			list_del(&prev_node->list);
 			list_add(&prev_node->list, &fd->victims);
-			log_printf_debug("add first victim %s", prev_node->name);
+			log_debug("add first victim %s", prev_node->name);
 			prev_node->init_victim = 1;
 		}
 	}
@@ -197,7 +196,7 @@ static void _add_victims(struct fd *fd, int start_type, int member_count,
 				list_add(&node->list, &fd->complete);
 			else {
 				list_add(&node->list, &fd->victims);
-				log_printf_debug("add victim %u, was leaving",
+				log_debug("add victim %u, was leaving",
 					  node->nodeid);
 			}
 		}
@@ -207,7 +206,7 @@ static void _add_victims(struct fd *fd, int start_type, int member_count,
 	 * to victims list or leaving list, depending on the type of start. */
 
 	if (list_empty(&fd->complete))
-		log_printf_debug("complete list empty warning");
+		log_debug("complete list empty warning");
 
 	list_for_each_entry_safe(node, safe, &fd->complete, list) {
 		if (!id_in_nodeids(node->nodeid, member_count, nodeids)) {
@@ -218,7 +217,7 @@ static void _add_victims(struct fd *fd, int start_type, int member_count,
 			else
 				list_add(&node->list, &fd->leaving);
 
-			log_printf_debug("add node %u to list %u", node->nodeid,
+			log_debug("add node %u to list %u", node->nodeid,
 				  start_type);
 		}
 	}
@@ -232,7 +231,7 @@ static void add_victims(struct fd *fd, int start_type, int member_count,
 	 * start/stop/start immediately upon joining. */
 
 	if (!fd->last_finish && fd->last_stop) {
-		log_printf_debug("revert aborted first start");
+		log_debug("revert aborted first start");
 		fd->last_stop = 0;
 		fd->first_recovery = 0;
 		free_node_list(&fd->prev);
@@ -240,7 +239,7 @@ static void add_victims(struct fd *fd, int start_type, int member_count,
 		free_node_list(&fd->leaving);
 	}
 
-	log_printf_debug("add_victims stop %d start %d finish %d",
+	log_debug("add_victims stop %d start %d finish %d",
 		  fd->last_stop, fd->last_start, fd->last_finish);
 
 	if (!fd->first_recovery) {
@@ -295,13 +294,13 @@ void process_groupd(int ci)
 
 	switch (cb_action) {
 	case DO_STOP:
-		log_printf_debug("stop %s", cb_name);
+		log_debug("stop %s", cb_name);
 		fd->last_stop = fd->last_start;
 		group_stop_done(gh, cb_name);
 		break;
 
 	case DO_START:
-		log_printf_debug("start %s %d members %s", cb_name, cb_event_nr,
+		log_debug("start %s %d members %s", cb_name, cb_event_nr,
 			  str_members());
 		fd->last_start = cb_event_nr;
 
@@ -321,7 +320,7 @@ void process_groupd(int ci)
 		break;
 
 	case DO_FINISH:
-		log_printf_debug("finish %s %d", cb_name, cb_event_nr);
+		log_debug("finish %s %d", cb_name, cb_event_nr);
 		fd->last_finish = cb_event_nr;
 
 		/* we get terminate callback when all have started, which means
@@ -331,9 +330,9 @@ void process_groupd(int ci)
 		break;
 
 	case DO_TERMINATE:
-		log_printf_debug("terminate %s", cb_name);
+		log_debug("terminate %s", cb_name);
 		if (!fd->leaving_group)
-			log_printf(LOG_ERR, "process_groupd terminate not leaving");
+			log_error("process_groupd terminate not leaving");
 		list_del(&fd->list);
 		free_fd(fd);
 		break;
@@ -355,12 +354,12 @@ int setup_groupd(void)
 
 	gh = group_init(NULL, "fence", 0, &callbacks, GROUPD_TIMEOUT);
 	if (!gh) {
-		log_printf(LOG_ERR, "group_init error %p %d", gh, errno);
+		log_error("group_init error %p %d", gh, errno);
 		return -ENOTCONN;
 	}
 	rv = group_get_fd(gh);
 	if (rv < 0)
-		log_printf(LOG_ERR, "group_get_fd error %d %d", rv, errno);
+		log_error("group_get_fd error %d %d", rv, errno);
 	return rv;
 }
 
@@ -380,7 +379,7 @@ int fd_join_group(struct fd *fd)
 
 	rv = group_join(gh, fd->name);
 	if (rv) {
-		log_printf(LOG_ERR, "group_join error %d", rv);
+		log_error("group_join error %d", rv);
 		list_del(&fd->list);
 		free(fd);
 	}
@@ -395,7 +394,7 @@ int fd_leave_group(struct fd *fd)
 
 	rv = group_leave(gh, fd->name);
 	if (rv)
-		log_printf(LOG_ERR, "group_leave error %d", rv);
+		log_error("group_leave error %d", rv);
 
 	return rv;
 }
diff --git a/fence/fenced/main.c b/fence/fenced/main.c
index 7048afa..83ca075 100644
--- a/fence/fenced/main.c
+++ b/fence/fenced/main.c
@@ -18,13 +18,6 @@ struct client {
 	void *deadfn;
 };
 
-LOGSYS_DECLARE_SYSTEM (NULL,
-	LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_OUTPUT_FILE | LOG_MODE_BUFFER_BEFORE_CONFIG,
-	LOGDIR "/fenced.log",
-	SYSLOGFACILITY);
-
-LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
-
 static int do_read(int fd, void *buf, size_t count)
 {
 	int rv, off = 0;
@@ -75,10 +68,10 @@ static void client_alloc(void)
 		pollfd = realloc(pollfd, (client_size + CLIENT_NALLOC) *
 					 sizeof(struct pollfd));
 		if (!pollfd)
-			log_printf(LOG_ERR, "can't alloc for pollfd");
+			log_error("can't alloc for pollfd");
 	}
 	if (!client || !pollfd)
-		log_printf(LOG_ERR, "can't alloc for client array");
+		log_error("can't alloc for client array");
 
 	for (i = client_size; i < client_size + CLIENT_NALLOC; i++) {
 		client[i].workfn = NULL;
@@ -198,7 +191,7 @@ static int do_join(char *name)
 
 	fd = find_fd(name);
 	if (fd) {
-		log_printf_debug("join error: domain %s exists", name);
+		log_debug("join error: domain %s exists", name);
 		rv = -EEXIST;
 		goto out;
 	}
@@ -413,17 +406,17 @@ static void process_connection(int ci)
 
 	rv = do_read(client[ci].fd, &h, sizeof(h));
 	if (rv < 0) {
-		log_printf_debug("connection %d read error %d", ci, rv);
+		log_debug("connection %d read error %d", ci, rv);
 		goto out;
 	}
 
 	if (h.magic != FENCED_MAGIC) {
-		log_printf_debug("connection %d magic error %x", ci, h.magic);
+		log_debug("connection %d magic error %x", ci, h.magic);
 		goto out;
 	}
 
 	if ((h.version & 0xFFFF0000) != (FENCED_VERSION & 0xFFFF0000)) {
-		log_printf_debug("connection %d version error %x", ci, h.version);
+		log_debug("connection %d version error %x", ci, h.version);
 		goto out;
 	}
 
@@ -431,14 +424,14 @@ static void process_connection(int ci)
 		extra_len = h.len - sizeof(h);
 		extra = malloc(extra_len);
 		if (!extra) {
-			log_printf(LOG_ERR, "process_connection no mem %d", extra_len);
+			log_error("process_connection no mem %d", extra_len);
 			goto out;
 		}
 		memset(extra, 0, extra_len);
 
 		rv = do_read(client[ci].fd, extra, extra_len);
 		if (rv < 0) {
-			log_printf_debug("connection %d extra read error %d", ci, rv);
+			log_debug("connection %d extra read error %d", ci, rv);
 			goto out;
 		}
 	}
@@ -457,10 +450,10 @@ static void process_connection(int ci)
 	case FENCED_CMD_NODE_INFO:
 	case FENCED_CMD_DOMAIN_INFO:
 	case FENCED_CMD_DOMAIN_NODES:
-		log_printf(LOG_ERR, "process_connection query on wrong socket");
+		log_error("process_connection query on wrong socket");
 		break;
 	default:
-		log_printf(LOG_ERR, "process_connection %d unknown command %d",
+		log_error("process_connection %d unknown command %d",
 			  ci, h.command);
 	}
  out:
@@ -475,13 +468,13 @@ static void process_listener(int ci)
 
 	fd = accept(client[ci].fd, NULL, NULL);
 	if (fd < 0) {
-		log_printf(LOG_ERR, "process_listener: accept error %d %d", fd, errno);
+		log_error("process_listener: accept error %d %d", fd, errno);
 		return;
 	}
 	
 	i = client_add(fd, process_connection, NULL);
 
-	log_printf_debug("client connection %d fd %d", i, fd);
+	log_debug("client connection %d fd %d", i, fd);
 }
 
 static int setup_listener(char *sock_path)
@@ -494,7 +487,7 @@ static int setup_listener(char *sock_path)
 
 	s = socket(AF_LOCAL, SOCK_STREAM, 0);
 	if (s < 0) {
-		log_printf(LOG_ERR, "socket error %d %d", s, errno);
+		log_error("socket error %d %d", s, errno);
 		return s;
 	}
 
@@ -505,14 +498,14 @@ static int setup_listener(char *sock_path)
 
 	rv = bind(s, (struct sockaddr *) &addr, addrlen);
 	if (rv < 0) {
-		log_printf(LOG_ERR, "bind error %d %d", rv, errno);
+		log_error("bind error %d %d", rv, errno);
 		close(s);
 		return rv;
 	}
 
 	rv = listen(s, 5);
 	if (rv < 0) {
-		log_printf(LOG_ERR, "listen error %d %d", rv, errno);
+		log_error("listen error %d %d", rv, errno);
 		close(s);
 		return rv;
 	}
@@ -593,7 +586,7 @@ static int setup_queries(void)
 
 	rv = pthread_create(&query_thread, NULL, process_queries, &s);
 	if (rv < 0) {
-		log_printf(LOG_ERR, "can't create query thread");
+		log_error("can't create query thread");
 		close(s);
 		return rv;
 	}
@@ -602,7 +595,7 @@ static int setup_queries(void)
 
 static void cluster_dead(int ci)
 {
-	log_printf(LOG_ERR, "cluster is down, exiting");
+	log_error("cluster is down, exiting");
 	exit(1);
 }
 
@@ -661,7 +654,7 @@ static int loop(void)
 			continue;
 		}
 		if (rv < 0) {
-			log_printf(LOG_ERR, "poll errno %d", errno);
+			log_error("poll errno %d", errno);
 			goto out;
 		}
 
@@ -770,7 +763,6 @@ static void read_arguments(int argc, char **argv)
 
 		case 'D':
 			daemon_debug_opt = 1;
-			daemon_fork = 1;
 			break;
 
 		case 'g':
@@ -862,24 +854,16 @@ int main(int argc, char **argv)
 
 	read_arguments(argc, argv);
 
-	if (daemon_debug_opt)
-		logsys_config_priority_set (LOG_LEVEL_DEBUG);
-
-	trylater = get_logsys_config_data();
-
-	if (trylater)
-		logsys_config_mode_set (LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_OUTPUT_FILE | LOG_MODE_FLUSH_AFTER_CONFIG);
-
 	lockfile();
 
-	if (!daemon_fork) {
+	if (!daemon_debug_opt) {
 		if (daemon(0, 0) < 0) {
-			log_printf(LOG_ERR, "main: cannot fork");
+			perror("main: cannot fork");
 			exit(EXIT_FAILURE);
 		}
 		umask(0);
 	}
-
+	openlog("fenced", LOG_PID, LOG_DAEMON);
 	signal(SIGTERM, sigterm_handler);
 
 	set_oom_adj(-16);
@@ -904,7 +888,6 @@ void daemon_dump_save(void)
 }
 
 int daemon_debug_opt;
-int daemon_fork = 0;
 int daemon_quit;
 struct list_head domains;
 int cman_quorate;
@@ -916,4 +899,4 @@ int dump_point;
 int dump_wrap;
 int group_mode;
 struct commandline comline;
-int trylater = 0;
+
diff --git a/fence/fenced/member_cman.c b/fence/fenced/member_cman.c
index 6ac6e1e..e85fcb6 100644
--- a/fence/fenced/member_cman.c
+++ b/fence/fenced/member_cman.c
@@ -7,7 +7,6 @@ static cman_handle_t	ch;
 static cman_node_t	cman_nodes[MAX_NODES];
 static int		cman_node_count;
 
-LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
 
 static int name_equal(char *name1, char *name2)
 {
@@ -100,7 +99,7 @@ static void statechange(void)
 
 	rv = cman_get_nodes(ch, MAX_NODES, &cman_node_count, cman_nodes);
 	if (rv < 0)
-		log_printf(LOG_ERR, "cman_get_nodes error %d %d", rv, errno);
+		log_error("cman_get_nodes error %d %d", rv, errno);
 }
 
 static void cman_callback(cman_handle_t h, void *private, int reason, int arg)
@@ -112,7 +111,7 @@ static void cman_callback(cman_handle_t h, void *private, int reason, int arg)
 		if (list_empty(&domains))
 			cman_replyto_shutdown(ch, 1);
 		else {
-			log_printf_debug("no to cman shutdown");
+			log_debug("no to cman shutdown");
 			cman_replyto_shutdown(ch, 0);
 		}
 		break;
@@ -132,7 +131,7 @@ void process_cman(int ci)
 
 	rv = cman_dispatch(ch, CMAN_DISPATCH_ALL);
 	if (rv == -1 && errno == EHOSTDOWN) {
-		log_printf(LOG_ERR, "cluster is down, exiting");
+		log_error("cluster is down, exiting");
 		exit(1);
 	}
 }
@@ -144,13 +143,13 @@ int setup_cman(void)
 
 	ch = cman_init(NULL);
 	if (!ch) {
-		log_printf(LOG_ERR, "cman_init error %p %d", ch, errno);
+		log_error("cman_init error %p %d", ch, errno);
 		return -ENOTCONN;
 	}
 
 	rv = cman_start_notification(ch, cman_callback);
 	if (rv < 0) {
-		log_printf(LOG_ERR, "cman_start_notification error %d %d", rv, errno);
+		log_error("cman_start_notification error %d %d", rv, errno);
 		cman_finish(ch);
 		return rv;
 	}
@@ -163,7 +162,7 @@ int setup_cman(void)
 	memset(&node, 0, sizeof(node));
 	rv = cman_get_node(ch, CMAN_NODEID_US, &node);
 	if (rv < 0) {
-		log_printf(LOG_ERR, "cman_get_node us error %d %d", rv, errno);
+		log_error("cman_get_node us error %d %d", rv, errno);
 		cman_finish(ch);
 		fd = rv;
 		goto out;
@@ -173,7 +172,7 @@ int setup_cman(void)
 	strncpy(our_name, node.cn_name, CMAN_MAX_NODENAME_LEN);
 	our_nodeid = node.cn_nodeid;
 
-	log_printf_debug("our_nodeid %d our_name %s", our_nodeid, our_name);
+	log_debug("our_nodeid %d our_name %s", our_nodeid, our_name);
  out:
 	return fd;
 }
@@ -197,7 +196,7 @@ int is_cman_member(int nodeid)
 	if (cn && cn->cn_member)
 		return 1;
 
-	log_printf_debug("node %d not a cman member, cn %d", nodeid, cn ? 1 : 0);
+	log_debug("node %d not a cman member, cn %d", nodeid, cn ? 1 : 0);
 	return 0;
 }
 
@@ -217,7 +216,7 @@ struct node *get_new_node(struct fd *fd, int nodeid)
 	memset(&cn, 0, sizeof(cn));
 	rv = cman_get_node(ch, nodeid, &cn);
 	if (rv < 0)
-		log_printf_debug("get_new_node %d no cman node %d", nodeid, rv);
+		log_debug("get_new_node %d no cman node %d", nodeid, rv);
 	else
 		strncpy(node->name, cn.cn_name, MAX_NODENAME_LEN);
 
diff --git a/fence/fenced/recover.c b/fence/fenced/recover.c
index 55d1a12..21bf735 100644
--- a/fence/fenced/recover.c
+++ b/fence/fenced/recover.c
@@ -1,7 +1,5 @@
 #include "fd.h"
 
-LOGSYS_DECLARE_SUBSYS ("FENCED", LOG_LEVEL_INFO);
-
 void free_node_list(struct list_head *head)
 {
 	struct node *node;
@@ -64,7 +62,7 @@ static int reduce_victims(struct fd *fd)
 
 	list_for_each_entry_safe(node, safe, &fd->victims, list) {
 		if (is_cman_member(node->nodeid)) {
-			log_printf_debug("reduce victim %s", node->name);
+			log_debug("reduce victim %s", node->name);
 			victim_done(fd, node->nodeid, VIC_DONE_MEMBER);
 			list_del(&node->list);
 			free(node);
@@ -118,7 +116,7 @@ static int check_override(int ofd, char *nodename, int timeout)
 
 	ret = select(ofd + 1, &rfds, NULL, NULL, &tv);
 	if (ret < 0) {
-		log_printf(LOG_ERR, "select: %s\n", strerror(errno));
+		syslog(LOG_ERR, "select: %s\n", strerror(errno));
 		return -1;
 	}
 
@@ -128,7 +126,7 @@ static int check_override(int ofd, char *nodename, int timeout)
 	memset(buf, 0, sizeof(buf));
 	ret = read(ofd, buf, sizeof(buf) - 1);
 	if (ret < 0) {
-		log_printf(LOG_ERR, "read: %s\n", strerror(errno));
+		syslog(LOG_ERR, "read: %s\n", strerror(errno));
 		return -1;
 	}
 
@@ -210,11 +208,11 @@ void delay_fencing(struct fd *fd, int node_join)
 
 	gettimeofday(&last, NULL);
 
-	log_printf_debug("delay of %ds leaves %d victims",
+	log_debug("delay of %ds leaves %d victims",
 		  (int) (last.tv_sec - first.tv_sec), victim_count);
  out:
 	list_for_each_entry(node, &fd->victims, list) {
-		log_printf(LOG_INFO, "%s not a cluster member after %d sec %s",
+		syslog(LOG_INFO, "%s not a cluster member after %d sec %s",
 		       node->name, delay, delay_type);
 	}
 }
@@ -228,8 +226,8 @@ void defer_fencing(struct fd *fd)
 
 	master_name = nodeid_to_name(fd->master);
 
-	log_printf_debug("defer fencing to %d %s", fd->master, master_name);
-	log_printf(LOG_INFO, "fencing deferred to %s", master_name);
+	log_debug("defer fencing to %d %s", fd->master, master_name);
+	syslog(LOG_INFO, "fencing deferred to %s", master_name);
 }
 
 void fence_victims(struct fd *fd)
@@ -249,7 +247,7 @@ void fence_victims(struct fd *fd)
 			fenced = 0;
 
 		if (member || fenced) {
-			log_printf_debug("averting fence of node %s "
+			log_debug("averting fence of node %s "
 				  "member %d external %d",
 				  node->name, member, fenced);
 			victim_done(fd, node->nodeid, member ? VIC_DONE_MEMBER :
@@ -259,14 +257,14 @@ void fence_victims(struct fd *fd)
 			continue;
 		}
 
-		log_printf_debug("fencing node %s", node->name);
-		log_printf(LOG_INFO, "fencing node \"%s\"", node->name);
+		log_debug("fencing node %s", node->name);
+		syslog(LOG_INFO, "fencing node \"%s\"", node->name);
 
 		query_unlock();
 		error = fence_node(node->name);
 		query_lock();
 
-		log_printf(LOG_INFO, "fence \"%s\" %s", node->name,
+		syslog(LOG_INFO, "fence \"%s\" %s", node->name,
 		       error ? "failed" : "success");
 
 		if (!error) {
@@ -288,7 +286,7 @@ void fence_victims(struct fd *fd)
 		override = open_override(comline.override_path);
 		if (check_override(override, node->name,
 				   comline.override_time) > 0) {
-			log_printf(LOG_WARNING, "fence \"%s\" overridden by "
+			syslog(LOG_WARNING, "fence \"%s\" overridden by "
 			       "administrator intervention", node->name);
 			victim_done(fd, node->nodeid, VIC_DONE_OVERRIDE);
 			list_del(&node->list);
-- 
1.5.3.6

-------------- next part --------------
>From: David Teigland <teigland@redhat.com>
>Date: Wed, 25 Jun 2008 15:56:34 -0500
>Subject: fenced: use openais logsys

Replace calls to syslog with calls to logsys, adding a ton of related
initialization and configuration.  The configuration also now allows
debug statements to be directed to logsys.

Signed-off-by: David Teigland <teigland@redhat.com>
---
 fence/fenced/config.c  |   44 ++++++++++++++++++-
 fence/fenced/fd.h      |   29 +++++++++++-
 fence/fenced/logging.c |  109 ++++++++++++++++++++++++++++++++++++++++++++++++
 fence/fenced/main.c    |    4 +-
 fence/fenced/recover.c |   18 ++++----
 5 files changed, 189 insertions(+), 15 deletions(-)
 create mode 100644 fence/fenced/logging.c

diff --git a/fence/fenced/config.c b/fence/fenced/config.c
index 56b7b0e..33fdbf4 100644
--- a/fence/fenced/config.c
+++ b/fence/fenced/config.c
@@ -1,7 +1,7 @@
 #include "fd.h"
 #include "ccs.h"
 
-static int open_ccs(void)
+int open_ccs(void)
 {
 	int i = 0, cd;
 
@@ -14,7 +14,47 @@ static int open_ccs(void)
 	return cd;
 }
 
-static void read_ccs_int(int cd, char *path, int *config_val)
+void close_ccs(int cd)
+{
+	ccs_disconnect(cd);
+}
+
+void read_ccs_name(int cd, char *path, char *name)
+{
+	char *str;
+	int error;
+
+	error = ccs_get(cd, path, &str);
+	if (error || !str)
+		return;
+
+	strcpy(name, str);
+
+	free(str);
+}
+
+void read_ccs_yesno(int cd, char *path, int *yes, int *no)
+{
+	char *str;
+	int error;
+
+	*yes = 0;
+	*no = 0;
+
+	error = ccs_get(cd, path, &str);
+	if (error || !str)
+		return;
+
+	if (!strcmp(str, "yes"))
+		*yes = 1;
+
+	else if (!strcmp(str, "no"))
+		*no = 1;
+
+	free(str);
+}
+
+void read_ccs_int(int cd, char *path, int *config_val)
 {
 	char *str;
 	int val;
diff --git a/fence/fenced/fd.h b/fence/fenced/fd.h
index 5ef1756..a222273 100644
--- a/fence/fenced/fd.h
+++ b/fence/fenced/fd.h
@@ -10,7 +10,6 @@
 #include <errno.h>
 #include <string.h>
 #include <stdint.h>
-#include <syslog.h>
 #include <time.h>
 #include <sched.h>
 #include <sys/ioctl.h>
@@ -24,6 +23,7 @@
 
 #include <openais/saAis.h>
 #include <openais/cpg.h>
+#include <openais/service/logsys.h>
 
 #include "list.h"
 #include "linux_endian.h"
@@ -58,6 +58,7 @@
 #define GROUP_LIBCPG            3
 
 extern int daemon_debug_opt;
+extern int daemon_debug_logsys;
 extern int daemon_quit;
 extern struct list_head domains;
 extern int cman_quorate;
@@ -74,14 +75,17 @@ extern void daemon_dump_save(void);
 #define log_debug(fmt, args...) \
 do { \
 	snprintf(daemon_debug_buf, 255, "%ld " fmt "\n", time(NULL), ##args); \
-	if (daemon_debug_opt) fprintf(stderr, "%s", daemon_debug_buf); \
 	daemon_dump_save(); \
+	if (daemon_debug_opt) \
+		fprintf(stderr, "%s", daemon_debug_buf); \
+	else if (daemon_debug_logsys) \
+		log_printf(LOG_DEBUG, "%s", daemon_debug_buf); \
 } while (0)
 
 #define log_error(fmt, args...) \
 do { \
 	log_debug(fmt, ##args); \
-	syslog(LOG_ERR, fmt, ##args); \
+	log_printf(LOG_ERR, fmt, ##args); \
 } while (0)
 
 /* config option defaults */
@@ -210,6 +214,11 @@ struct fd {
 
 /* config.c */
 
+int open_ccs(void);
+void close_ccs(int cd);
+void read_ccs_name(int cd, char *path, char *name);
+void read_ccs_yesno(int cd, char *path, int *yes, int *no);
+void read_ccs_int(int cd, char *path, int *config_val);
 int read_ccs(struct fd *fd);
 
 /* cpg.c */
@@ -266,5 +275,19 @@ void delay_fencing(struct fd *fd, int node_join);
 void defer_fencing(struct fd *fd);
 void fence_victims(struct fd *fd);
 
+/* logging.c */
+
+void setup_logsys(void);
+
+/* logsys magic */
+
+#ifdef MAIN_INCLUDE
+LOGSYS_DECLARE_SYSTEM(NULL,
+	LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_OUTPUT_FILE | LOG_MODE_BUFFER_BEFORE_CONFIG,
+	LOGDIR "/fenced.log",
+	SYSLOGFACILITY);
+#endif
+LOGSYS_DECLARE_SUBSYS("FENCED", LOG_LEVEL_INFO);
+
 #endif				/*  __FD_DOT_H__  */
 
diff --git a/fence/fenced/logging.c b/fence/fenced/logging.c
new file mode 100644
index 0000000..38abc21
--- /dev/null
+++ b/fence/fenced/logging.c
@@ -0,0 +1,109 @@
+#include "fd.h"
+
+#define LEVEL_PATH "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@syslog_level"
+#define DEBUG_PATH "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@debug"
+
+static int get_logsys_config_data(void)
+{
+	int fd, level, loglevel, facility, y, n;
+	unsigned int logmode;
+	char name[PATH_MAX];
+	char *error; /* eh? */
+
+	fd = open_ccs();
+	if (fd < 0)
+		return fd;
+
+	/*
+	 * set level
+	 */
+
+	read_ccs_int(fd, LEVEL_PATH, &level);
+
+	loglevel = logsys_priority_id_get(level);
+	if (loglevel < 0)
+		loglevel = LOG_LEVEL_INFO;
+
+	logsys_config_priority_set(loglevel);
+
+	/*
+	 * set mode
+	 */
+
+	logmode = logsys_config_mode_get();
+
+	read_ccs_yesno(fd, "/cluster/logging/@to_stderr", &y, &n);
+	if (y)
+		logmode |= LOG_MODE_OUTPUT_STDERR;
+	if (n)
+		logmode &= ~LOG_MODE_OUTPUT_STDERR;
+
+	read_ccs_yesno(fd, "/cluster/logging/@to_syslog", &y, &n);
+	if (y)
+		logmode |= LOG_MODE_OUTPUT_SYSLOG_THREADED;
+	if (n)
+		logmode &= ~LOG_MODE_OUTPUT_SYSLOG_THREADED;
+
+	read_ccs_yesno(fd, "/cluster/logging/@to_file", &y, &n);
+	if (y)
+		logmode |= LOG_MODE_OUTPUT_FILE;
+	if (n)
+		logmode &= ~LOG_MODE_OUTPUT_FILE;
+
+	if (logmode & LOG_MODE_BUFFER_BEFORE_CONFIG) {
+		logmode &= ~LOG_MODE_BUFFER_BEFORE_CONFIG;
+		logmode |= LOG_MODE_FLUSH_AFTER_CONFIG;
+		logsys_config_mode_set(logmode);
+	}
+
+	/*
+	 * set log file
+	 */
+	
+	memset(name, 0, sizeof(name));
+	read_ccs_name(fd, "/cluster/logging/@filename", name);
+
+	if (name[0])
+		logsys_config_file_set(&error, name);
+
+	/*
+	 * set facility
+	 */
+
+	memset(name, 0, sizeof(name));
+	read_ccs_name(fd, "/cluster/logging/@syslog_facility", name);
+
+	facility = logsys_facility_get(name);
+	if (facility < 0)
+		facility = SYSLOGFACILITY;
+
+	logsys_config_facility_set("FENCED", facility);
+
+	/*
+	 * set debug (wish this was yes/no like above)
+	 */
+
+	memset(name, 0, sizeof(name));
+	read_ccs_name(fd, "/cluster/logging/@debug", name);
+
+	if (!strcmp(name, "on"))
+		daemon_debug_logsys = 1;
+
+	memset(name, 0, sizeof(name));
+	read_ccs_name(fd, DEBUG_PATH, name);
+
+	if (!strcmp(name, "on"))
+		daemon_debug_logsys = 1;
+
+	close_ccs(fd);
+}
+
+void setup_logsys(void)
+{
+	get_logsys_config_data();
+	logsys_config_mode_set(LOG_MODE_OUTPUT_STDERR |
+			       LOG_MODE_OUTPUT_SYSLOG_THREADED |
+			       LOG_MODE_OUTPUT_FILE |
+			       LOG_MODE_FLUSH_AFTER_CONFIG);
+}
+
diff --git a/fence/fenced/main.c b/fence/fenced/main.c
index 83ca075..575aecb 100644
--- a/fence/fenced/main.c
+++ b/fence/fenced/main.c
@@ -1,3 +1,4 @@
+#define MAIN_INCLUDE
 #include "fd.h"
 #include "pthread.h"
 #include "copyright.cf"
@@ -863,7 +864,7 @@ int main(int argc, char **argv)
 		}
 		umask(0);
 	}
-	openlog("fenced", LOG_PID, LOG_DAEMON);
+	setup_logsys();
 	signal(SIGTERM, sigterm_handler);
 
 	set_oom_adj(-16);
@@ -888,6 +889,7 @@ void daemon_dump_save(void)
 }
 
 int daemon_debug_opt;
+int daemon_debug_logsys;
 int daemon_quit;
 struct list_head domains;
 int cman_quorate;
diff --git a/fence/fenced/recover.c b/fence/fenced/recover.c
index 21bf735..e3bf7e1 100644
--- a/fence/fenced/recover.c
+++ b/fence/fenced/recover.c
@@ -116,7 +116,7 @@ static int check_override(int ofd, char *nodename, int timeout)
 
 	ret = select(ofd + 1, &rfds, NULL, NULL, &tv);
 	if (ret < 0) {
-		syslog(LOG_ERR, "select: %s\n", strerror(errno));
+		log_printf(LOG_ERR, "select: %s\n", strerror(errno));
 		return -1;
 	}
 
@@ -126,7 +126,7 @@ static int check_override(int ofd, char *nodename, int timeout)
 	memset(buf, 0, sizeof(buf));
 	ret = read(ofd, buf, sizeof(buf) - 1);
 	if (ret < 0) {
-		syslog(LOG_ERR, "read: %s\n", strerror(errno));
+		log_printf(LOG_ERR, "read: %s\n", strerror(errno));
 		return -1;
 	}
 
@@ -212,8 +212,8 @@ void delay_fencing(struct fd *fd, int node_join)
 		  (int) (last.tv_sec - first.tv_sec), victim_count);
  out:
 	list_for_each_entry(node, &fd->victims, list) {
-		syslog(LOG_INFO, "%s not a cluster member after %d sec %s",
-		       node->name, delay, delay_type);
+		log_printf(LOG_INFO, "%s not a cluster member after %d sec %s",
+		           node->name, delay, delay_type);
 	}
 }
 
@@ -227,7 +227,7 @@ void defer_fencing(struct fd *fd)
 	master_name = nodeid_to_name(fd->master);
 
 	log_debug("defer fencing to %d %s", fd->master, master_name);
-	syslog(LOG_INFO, "fencing deferred to %s", master_name);
+	log_printf(LOG_INFO, "fencing deferred to %s", master_name);
 }
 
 void fence_victims(struct fd *fd)
@@ -258,13 +258,13 @@ void fence_victims(struct fd *fd)
 		}
 
 		log_debug("fencing node %s", node->name);
-		syslog(LOG_INFO, "fencing node \"%s\"", node->name);
+		log_printf(LOG_INFO, "fencing node \"%s\"", node->name);
 
 		query_unlock();
 		error = fence_node(node->name);
 		query_lock();
 
-		syslog(LOG_INFO, "fence \"%s\" %s", node->name,
+		log_printf(LOG_INFO, "fence \"%s\" %s", node->name,
 		       error ? "failed" : "success");
 
 		if (!error) {
@@ -286,8 +286,8 @@ void fence_victims(struct fd *fd)
 		override = open_override(comline.override_path);
 		if (check_override(override, node->name,
 				   comline.override_time) > 0) {
-			syslog(LOG_WARNING, "fence \"%s\" overridden by "
-			       "administrator intervention", node->name);
+			log_printf(LOG_WARNING, "fence \"%s\" overridden by "
+				   "administrator intervention", node->name);
 			victim_done(fd, node->nodeid, VIC_DONE_OVERRIDE);
 			list_del(&node->list);
 			free(node);
-- 
1.5.3.6


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-25 21:21 David Teigland
@ 2008-06-26  3:48 ` Fabio M. Di Nitto
  2008-06-26 14:05   ` David Teigland
  2008-06-26 21:43 ` David Teigland
  1 sibling, 1 reply; 19+ messages in thread
From: Fabio M. Di Nitto @ 2008-06-26  3:48 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Wed, 25 Jun 2008, David Teigland wrote:

> Attached two patches:
>  fenced-revert.patch reverts the current logsys changes to fenced.

If you revert, please do it by meaning of git-revert.

>  fenced-logsys.patch is my own logsys conversion for fenced.
>
> I've not compiled or tested these patches yet (the version of openais I
> have working on my test machines does not have logsys and I don't want to
> disrupt my tests on those machines.)  I'll push these once they compile.
>
> I have yet to study logsys enough to propose an alternative to the macro
> magic that's now isolated at the end of fd.h.

There are few things that don't work in this patch.

diff --git a/fence/fenced/config.c b/fence/fenced/config.c
index 56b7b0e..33fdbf4 100644
--- a/fence/fenced/config.c
+++ b/fence/fenced/config.c
@@ -1,7 +1,7 @@
  #include "fd.h"
  #include "ccs.h"

-static int open_ccs(void)
+int open_ccs(void)
  {
  	int i = 0, cd;

@@ -14,7 +14,47 @@ static int open_ccs(void)
  	return cd;
  }

^^ You can't use open_ccs within get_logsys_config_data. open_ccs uses 
log_printf to log. If it's waiting for ccs, but logging is not available 
yet, you end up with no information of what is going on.

In the original code, we try once to access the config data. If it works 
good, otherwise we config logsys manually enough to log what is happening
and we try later. You are missing this fallback mechanism.

@@ -74,14 +75,17 @@ extern void daemon_dump_save(void);
  #define log_debug(fmt, args...) \
  do { \
  	snprintf(daemon_debug_buf, 255, "%ld " fmt "\n", time(NULL), ##args); \
-	if (daemon_debug_opt) fprintf(stderr, "%s", daemon_debug_buf); \
  	daemon_dump_save(); \
+	if (daemon_debug_opt) \
+		fprintf(stderr, "%s", daemon_debug_buf); \
+	else if (daemon_debug_logsys) \
+		log_printf(LOG_DEBUG, "%s", daemon_debug_buf); \
  } while (0)

Can those 2 go in parallel?

+       if (daemon_debug_opt) \
+               fprintf(stderr, "%s", daemon_debug_buf); \
+       if (daemon_debug_logsys) \
+               log_printf(LOG_DEBUG, "%s", daemon_debug_buf); \

so that users can decide which one they want without worrying about 
preferences?

diff --git a/fence/fenced/logging.c b/fence/fenced/logging.c
new file mode 100644
index 0000000..38abc21
--- /dev/null
+++ b/fence/fenced/logging.c
@@ -0,0 +1,109 @@
+#include "fd.h"
+
+#define LEVEL_PATH "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@syslog_level"
+#define DEBUG_PATH "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@debug"
+
+static int get_logsys_config_data(void)

Most of the configuration logic is wrong and you don't check for a bunch 
of return codes that could at least inform you or the users of the status 
of the configuration.

+{
+	int fd, level, loglevel, facility, y, n;
+	unsigned int logmode;
+	char name[PATH_MAX];
+	char *error; /* eh? */

This is for logsys file set. If the call fails to open a file it tells you 
why there.

+
+	fd = open_ccs();
+	if (fd < 0)
+		return fd;
+
+	/*
+	 * set level
+	 */
+
+	read_ccs_int(fd, LEVEL_PATH, &level);
+
+	loglevel = logsys_priority_id_get(level);
+	if (loglevel < 0)
+		loglevel = LOG_LEVEL_INFO;
+
+	logsys_config_priority_set(loglevel);
+
+	/*
+	 * set mode
+	 */
+
+	logmode = logsys_config_mode_get();
+
+	read_ccs_yesno(fd, "/cluster/logging/@to_stderr", &y, &n);
+	if (y)
+		logmode |= LOG_MODE_OUTPUT_STDERR;
+	if (n)
+		logmode &= ~LOG_MODE_OUTPUT_STDERR;
+
+	read_ccs_yesno(fd, "/cluster/logging/@to_syslog", &y, &n);
+	if (y)
+		logmode |= LOG_MODE_OUTPUT_SYSLOG_THREADED;
+	if (n)
+		logmode &= ~LOG_MODE_OUTPUT_SYSLOG_THREADED;
+
+	read_ccs_yesno(fd, "/cluster/logging/@to_file", &y, &n);
+	if (y)
+		logmode |= LOG_MODE_OUTPUT_FILE;
+	if (n)
+		logmode &= ~LOG_MODE_OUTPUT_FILE;
+
+	if (logmode & LOG_MODE_BUFFER_BEFORE_CONFIG) {
+		logmode &= ~LOG_MODE_BUFFER_BEFORE_CONFIG;
+		logmode |= LOG_MODE_FLUSH_AFTER_CONFIG;
+		logsys_config_mode_set(logmode);
+	}

^^^

This one will init logsys before you have finished setting it up.

+
+	/*
+	 * set log file
+	 */
+ 
+	memset(name, 0, sizeof(name));
+	read_ccs_name(fd, "/cluster/logging/@filename", name);
+
+	if (name[0])
+		logsys_config_file_set(&error, name);
+
+	/*
+	 * set facility
+	 */
+
+	memset(name, 0, sizeof(name));
+	read_ccs_name(fd, "/cluster/logging/@syslog_facility", name);
+
+	facility = logsys_facility_get(name);
+	if (facility < 0)
+		facility = SYSLOGFACILITY;
+
+	logsys_config_facility_set("FENCED", facility);
+
+	/*
+	 * set debug (wish this was yes/no like above)
+	 */
+
+	memset(name, 0, sizeof(name));
+	read_ccs_name(fd, "/cluster/logging/@debug", name);
+
+	if (!strcmp(name, "on"))
+		daemon_debug_logsys = 1;
+
+	memset(name, 0, sizeof(name));
+	read_ccs_name(fd, DEBUG_PATH, name);
+
+	if (!strcmp(name, "on"))
+		daemon_debug_logsys = 1;
+
+	close_ccs(fd);

Debug needs to be checked before log_level. In logsys debug=on is 
equivalent of setting syslog_level=debug. The original code I proposed 
does:

debug from the envvar (that i missed in my original patch) > debug from 
cmdline > subsystem config debug option > global config debug option.

This allows you a great deal of flexibility to specify: I want all debug 
on except for this or that subsystem, or i want debugging off, except 
for.. etc.

Then you set log_level according to that.

+}
+
+void setup_logsys(void)
+{
+	get_logsys_config_data();
+	logsys_config_mode_set(LOG_MODE_OUTPUT_STDERR |
+			       LOG_MODE_OUTPUT_SYSLOG_THREADED |
+			       LOG_MODE_OUTPUT_FILE |
+			       LOG_MODE_FLUSH_AFTER_CONFIG);
+}

this call to logsys_config_mode_set will simply override all the 
configyration you did for STDERR SYSLOG_THREADED and FILE by setting them 
all back on.

Fabio

--
I'm going to make him an offer he can't refuse.



^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-26  3:48 ` Fabio M. Di Nitto
@ 2008-06-26 14:05   ` David Teigland
  2008-06-27  3:45     ` Fabio M. Di Nitto
  0 siblings, 1 reply; 19+ messages in thread
From: David Teigland @ 2008-06-26 14:05 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Thu, Jun 26, 2008 at 05:48:56AM +0200, Fabio M. Di Nitto wrote:
> On Wed, 25 Jun 2008, David Teigland wrote:
> 
> >Attached two patches:
> > fenced-revert.patch reverts the current logsys changes to fenced.
> 
> If you revert, please do it by meaning of git-revert.

That was a series of git-revert -n which the man page suggested:

"This is useful when reverting more than one commits' effect to
 your working tree in a row."


> ^^ You can't use open_ccs within get_logsys_config_data. open_ccs uses 
> log_printf to log. If it's waiting for ccs, but logging is not available 
> yet, you end up with no information of what is going on.
> 
> In the original code, we try once to access the config data. If it works 
> good, otherwise we config logsys manually enough to log what is happening
> and we try later. You are missing this fallback mechanism.

I think I'll just avoid all the chicken/egg complication by not logging in
in open_ccs.  I expect it should be nearly impossible for ccs_connect() to
fail now with the new ccs.  (Previously, ccs_connect would always fail
leaving people wondering why nothing was happening, which is why we added
the logging.  One of the goals of the new ccs is that reading the config
should basically never fail.)


> @@ -74,14 +75,17 @@ extern void daemon_dump_save(void);
>  #define log_debug(fmt, args...) \
>  do { \
>  	snprintf(daemon_debug_buf, 255, "%ld " fmt "\n", time(NULL), 
>  	##args); \
> -	if (daemon_debug_opt) fprintf(stderr, "%s", daemon_debug_buf); \
>  	daemon_dump_save(); \
> +	if (daemon_debug_opt) \
> +		fprintf(stderr, "%s", daemon_debug_buf); \
> +	else if (daemon_debug_logsys) \
> +		log_printf(LOG_DEBUG, "%s", daemon_debug_buf); \
>  } while (0)
> 
> Can those 2 go in parallel?
> 
> +       if (daemon_debug_opt) \
> +               fprintf(stderr, "%s", daemon_debug_buf); \
> +       if (daemon_debug_logsys) \
> +               log_printf(LOG_DEBUG, "%s", daemon_debug_buf); \
> 
> so that users can decide which one they want without worrying about 
> preferences?

daemon_debug_opt and daemon_debug_logsys are mutually exclusive by
definition; you don't want or need logsys when you're running with -D.


> diff --git a/fence/fenced/logging.c b/fence/fenced/logging.c
> new file mode 100644
> index 0000000..38abc21
> --- /dev/null
> +++ b/fence/fenced/logging.c
> @@ -0,0 +1,109 @@
> +#include "fd.h"
> +
> +#define LEVEL_PATH 
> "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@syslog_level"
> +#define DEBUG_PATH 
> "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@debug"
> +
> +static int get_logsys_config_data(void)
> 
> Most of the configuration logic is wrong and you don't check for a bunch 
> of return codes that could at least inform you or the users of the status 
> of the configuration.

Yeah, not understanding logsys, I couldn't make sense of the logic that
was there, it was "non-obvious", so I just tried to copy it.  I obviously
have a lot of logsys study to do, hopefully suggesting some
simplifications along the way...


> Debug needs to be checked before log_level. In logsys debug=on is 
> equivalent of setting syslog_level=debug. The original code I proposed 
> does:
> 
> debug from the envvar (that i missed in my original patch) > debug from 
> cmdline > subsystem config debug option > global config debug option.
> 
> This allows you a great deal of flexibility to specify: I want all debug 
> on except for this or that subsystem, or i want debugging off, except 
> for.. etc.
> 
> Then you set log_level according to that.

that sounds like a great deal of complexity for something that shouldn't
deserve it.


> +void setup_logsys(void)
> +{
> +	get_logsys_config_data();
> +	logsys_config_mode_set(LOG_MODE_OUTPUT_STDERR |
> +			       LOG_MODE_OUTPUT_SYSLOG_THREADED |
> +			       LOG_MODE_OUTPUT_FILE |
> +			       LOG_MODE_FLUSH_AFTER_CONFIG);
> +}
> 
> this call to logsys_config_mode_set will simply override all the 
> configyration you did for STDERR SYSLOG_THREADED and FILE by setting them 
> all back on.

That puzzled me, too... ah, looks like I mistranslated the original code.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-25 21:21 David Teigland
  2008-06-26  3:48 ` Fabio M. Di Nitto
@ 2008-06-26 21:43 ` David Teigland
  2008-06-27 15:06   ` David Teigland
  1 sibling, 1 reply; 19+ messages in thread
From: David Teigland @ 2008-06-26 21:43 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Wed, Jun 25, 2008 at 04:21:55PM -0500, David Teigland wrote:
> I have yet to study logsys enough to propose an alternative to the macro
> magic that's now isolated at the end of fd.h.

I've done some logsys studying and discussed it with Steve Dake.  The
logsys implementation and api is heavily geared toward use by openais
plugins (see the entire notion of "subsystems" that logsys is built
around).  Using it from a general program like fenced, not an
openais-plugin, makes the mismatch painfully clear.

So, I don't hold out much hope that logsys is going to be useful for
non-plugins.  But, just because we don't share the actual code that
performs logging, doesn't mean we can't have a uniform approach for
setting up logging properies for all cluster-related programs.  That may
still be a worthwhile goal.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-26 14:05   ` David Teigland
@ 2008-06-27  3:45     ` Fabio M. Di Nitto
  2008-06-27 15:12       ` Fabio M. Di Nitto
  0 siblings, 1 reply; 19+ messages in thread
From: Fabio M. Di Nitto @ 2008-06-27  3:45 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Thu, 26 Jun 2008, David Teigland wrote:

> On Thu, Jun 26, 2008 at 05:48:56AM +0200, Fabio M. Di Nitto wrote:
>> On Wed, 25 Jun 2008, David Teigland wrote:
>>
>>> Attached two patches:
>>> fenced-revert.patch reverts the current logsys changes to fenced.
>>
>> If you revert, please do it by meaning of git-revert.
>
> That was a series of git-revert -n which the man page suggested:
>
> "This is useful when reverting more than one commits' effect to
> your working tree in a row."

I missed the git header and I thought you were going to revert by meaning 
of one single manual patch.

>
>> ^^ You can't use open_ccs within get_logsys_config_data. open_ccs uses
>> log_printf to log. If it's waiting for ccs, but logging is not available
>> yet, you end up with no information of what is going on.
>>
>> In the original code, we try once to access the config data. If it works
>> good, otherwise we config logsys manually enough to log what is happening
>> and we try later. You are missing this fallback mechanism.
>
> I think I'll just avoid all the chicken/egg complication by not logging in
> in open_ccs.

So if you can't connect to ccs/objdb, we will have another daemon waiting 
for something and users will have no idea what.

>  I expect it should be nearly impossible for ccs_connect() to
> fail now with the new ccs.

Based on what assumption?

Anyway this is another pandora's box to open and should be handled in 
another thread. We have X different half baked solutions to connected to 
libccs and cman. None of them do it right. There is space for a little 
common library that handles it properly and it's not the first time that 
this issue comes up so maybe it's time to address it.

>  (Previously, ccs_connect would always fail
> leaving people wondering why nothing was happening, which is why we added
> the logging.  One of the goals of the new ccs is that reading the config
> should basically never fail.)

eh? so if cman/objdb are not available then what?

>
>
>> @@ -74,14 +75,17 @@ extern void daemon_dump_save(void);
>>  #define log_debug(fmt, args...) \
>>  do { \
>>  	snprintf(daemon_debug_buf, 255, "%ld " fmt "\n", time(NULL),
>>  	##args); \
>> -	if (daemon_debug_opt) fprintf(stderr, "%s", daemon_debug_buf); \
>>  	daemon_dump_save(); \
>> +	if (daemon_debug_opt) \
>> +		fprintf(stderr, "%s", daemon_debug_buf); \
>> +	else if (daemon_debug_logsys) \
>> +		log_printf(LOG_DEBUG, "%s", daemon_debug_buf); \
>>  } while (0)
>>
>> Can those 2 go in parallel?
>>
>> +       if (daemon_debug_opt) \
>> +               fprintf(stderr, "%s", daemon_debug_buf); \
>> +       if (daemon_debug_logsys) \
>> +               log_printf(LOG_DEBUG, "%s", daemon_debug_buf); \
>>
>> so that users can decide which one they want without worrying about
>> preferences?
>
> daemon_debug_opt and daemon_debug_logsys are mutually exclusive by
> definition; you don't want or need logsys when you're running with -D.

Who says? i don't use -D, but i set debug=on and i get the exact same 
results. Output to stderr included if i don't fork.

>
>
>> diff --git a/fence/fenced/logging.c b/fence/fenced/logging.c
>> new file mode 100644
>> index 0000000..38abc21
>> --- /dev/null
>> +++ b/fence/fenced/logging.c
>> @@ -0,0 +1,109 @@
>> +#include "fd.h"
>> +
>> +#define LEVEL_PATH
>> "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@syslog_level"
>> +#define DEBUG_PATH
>> "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@debug"
>> +
>> +static int get_logsys_config_data(void)
>>
>> Most of the configuration logic is wrong and you don't check for a bunch
>> of return codes that could at least inform you or the users of the status
>> of the configuration.
>
> Yeah, not understanding logsys, I couldn't make sense of the logic that
> was there, it was "non-obvious", so I just tried to copy it.  I obviously
> have a lot of logsys study to do, hopefully suggesting some
> simplifications along the way...

The configuration is dead easy. It was there. You could have just replaced 
my strcmp with your read_ccsyes/no thingy and it would have work without 
you having to spend this incredible amount of time on logsys.

>
>
>> Debug needs to be checked before log_level. In logsys debug=on is
>> equivalent of setting syslog_level=debug. The original code I proposed
>> does:
>>
>> debug from the envvar (that i missed in my original patch) > debug from
>> cmdline > subsystem config debug option > global config debug option.
>>
>> This allows you a great deal of flexibility to specify: I want all debug
>> on except for this or that subsystem, or i want debugging off, except
>> for.. etc.
>>
>> Then you set log_level according to that.
>
> that sounds like a great deal of complexity for something that shouldn't
> deserve it.

It's not complex at all. It saves you a log of ccs interactions if you set 
debug from the command line and it allows you to do fine tuned debugging 
per subsystem.

Fabio

--
I'm going to make him an offer he can't refuse.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-26 21:43 ` David Teigland
@ 2008-06-27 15:06   ` David Teigland
  2008-06-27 15:16     ` Fabio M. Di Nitto
  2008-06-28  3:27     ` Joel Becker
  0 siblings, 2 replies; 19+ messages in thread
From: David Teigland @ 2008-06-27 15:06 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Thu, Jun 26, 2008 at 04:43:28PM -0500, David Teigland wrote:
> On Wed, Jun 25, 2008 at 04:21:55PM -0500, David Teigland wrote:
> > I have yet to study logsys enough to propose an alternative to the macro
> > magic that's now isolated at the end of fd.h.
> 
> I've done some logsys studying and discussed it with Steve Dake.  The
> logsys implementation and api is heavily geared toward use by openais
> plugins (see the entire notion of "subsystems" that logsys is built
> around).  Using it from a general program like fenced, not an
> openais-plugin, makes the mismatch painfully clear.
> 
> So, I don't hold out much hope that logsys is going to be useful for
> non-plugins.  But, just because we don't share the actual code that
> performs logging, doesn't mean we can't have a uniform approach for
> setting up logging properies for all cluster-related programs.  That may
> still be a worthwhile goal.

The hope that I do still hold out for using logsys, is that we may be able
to develop a simple syslog-like api for it, that would either parallel or
sit above the plugin-oriented api that's there now.  Steve claims that the
syslog(3) api is fundamentally broken and didn't sound at all interested
in the idea, but maybe others are more open to the idea?



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-27  3:45     ` Fabio M. Di Nitto
@ 2008-06-27 15:12       ` Fabio M. Di Nitto
  0 siblings, 0 replies; 19+ messages in thread
From: Fabio M. Di Nitto @ 2008-06-27 15:12 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Fri, 27 Jun 2008, Fabio M. Di Nitto wrote:

> Anyway this is another pandora's box to open and should be handled in another 
> thread. We have X different half baked solutions to connected to libccs and 
> cman. None of them do it right. There is space for a little common library 
> that handles it properly and it's not the first time that this issue comes up 
> so maybe it's time to address it.

For this specific issue i posted another message to cluster-devel.

http://www.redhat.com/archives/cluster-devel/2008-June/msg00217.html

Fabio

--
I'm going to make him an offer he can't refuse.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-27 15:06   ` David Teigland
@ 2008-06-27 15:16     ` Fabio M. Di Nitto
  2008-06-28  3:27     ` Joel Becker
  1 sibling, 0 replies; 19+ messages in thread
From: Fabio M. Di Nitto @ 2008-06-27 15:16 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Fri, 27 Jun 2008, David Teigland wrote:

> On Thu, Jun 26, 2008 at 04:43:28PM -0500, David Teigland wrote:
>> On Wed, Jun 25, 2008 at 04:21:55PM -0500, David Teigland wrote:
>>> I have yet to study logsys enough to propose an alternative to the macro
>>> magic that's now isolated at the end of fd.h.
>>
>> I've done some logsys studying and discussed it with Steve Dake.  The
>> logsys implementation and api is heavily geared toward use by openais
>> plugins (see the entire notion of "subsystems" that logsys is built
>> around).  Using it from a general program like fenced, not an
>> openais-plugin, makes the mismatch painfully clear.
>>
>> So, I don't hold out much hope that logsys is going to be useful for
>> non-plugins.  But, just because we don't share the actual code that
>> performs logging, doesn't mean we can't have a uniform approach for
>> setting up logging properies for all cluster-related programs.  That may
>> still be a worthwhile goal.
>
> The hope that I do still hold out for using logsys, is that we may be able
> to develop a simple syslog-like api for it, that would either parallel or
> sit above the plugin-oriented api that's there now.  Steve claims that the
> syslog(3) api is fundamentally broken and didn't sound at all interested
> in the idea, but maybe others are more open to the idea?

My goal is to have a common logging infrastructure with the same options 
all over and that will provide the same output etc. for virtually
everything as possible where it makes sense (daemons basically).

If you want to develop a parallel API or an API that sits on top, it's 
fine by me. Tho you will also have to take the responsibility to convert 
all code to use it, and update documentation and retain backward
compatibility for cman/qdisk/rgmanager that had already their own config 
sets prior logsys. I for sure don't want see again half code converted and 
half not.

In my head it sounds a lot of extra work to do but for sure i am not going 
to stop you, as long this is done before we declare our API stable for 3.0 
(that should happen within a reasonable amount of time == a month max).

Fabio

--
I'm going to make him an offer he can't refuse.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-27 15:06   ` David Teigland
  2008-06-27 15:16     ` Fabio M. Di Nitto
@ 2008-06-28  3:27     ` Joel Becker
  2008-06-28  3:50       ` Steven Dake
  1 sibling, 1 reply; 19+ messages in thread
From: Joel Becker @ 2008-06-28  3:27 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Fri, Jun 27, 2008 at 10:06:01AM -0500, David Teigland wrote:
> The hope that I do still hold out for using logsys, is that we may be able
> to develop a simple syslog-like api for it, that would either parallel or
> sit above the plugin-oriented api that's there now.  Steve claims that the
> syslog(3) api is fundamentally broken and didn't sound at all interested
> in the idea, but maybe others are more open to the idea?

	I wonder what's fundamentally broken about it.  I'm sorry that
logsys doesn't use syslog internally - how does it log remotely, for
example? :-)

Joel

-- 

Life's Little Instruction Book #94

	"Make it a habit to do nice things for people who 
	 will never find out."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127



^ permalink raw reply	[flat|nested] 19+ messages in thread

* [Cluster-devel] logsys in fenced
  2008-06-28  3:27     ` Joel Becker
@ 2008-06-28  3:50       ` Steven Dake
  0 siblings, 0 replies; 19+ messages in thread
From: Steven Dake @ 2008-06-28  3:50 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Fri, 2008-06-27 at 20:27 -0700, Joel Becker wrote:
> On Fri, Jun 27, 2008 at 10:06:01AM -0500, David Teigland wrote:
> > The hope that I do still hold out for using logsys, is that we may be able
> > to develop a simple syslog-like api for it, that would either parallel or
> > sit above the plugin-oriented api that's there now.  Steve claims that the
> > syslog(3) api is fundamentally broken and didn't sound at all interested
> > in the idea, but maybe others are more open to the idea?
> 
> 	I wonder what's fundamentally broken about it.  I'm sorry that
> logsys doesn't use syslog internally - how does it log remotely, for
> example? :-)
> 
> Joel
> 

The syslog api has served thousands of applications for 20+ years.  But
the fact is every single application that is significant develops their
own logging solution because, frankly, the syslog API is a POS.

The logsys API does use the syslogd daemon's ipc connection but not the
c library api which is fundamentally flawed.  As a result we support all
of the syslogd features that system administrators have come to know and
love, and doesn't change any of those features at all!

For logging remotely, all of that is managed by syslogd.  Syslogd is a
great system.  My sole issue is with the c library api
syslog/openlog/closelog friends.  They were designed in 1970's and are
missing some key features.  This is the motivation behind logsys.
LOGSYS IS A REPLACEMENT for SYSLOG(3) NOT SYSLOGD.  It is 100%
compatabile with the syslogd daemon shipped in every single distribution
in the world.

The logsys api is not "plugin oriented"; it is designed for large
software projects that have several components each of which may desire
to log specific information at different levels, to different files, or
with different tracing levels about different subsystems.  Also the
syslog api itself is broken because is does not allow nonblocking IO
without the loss of log messages.

None of this is supported by the syslog api which is why it is
insufficient.

But I can tell I'm talking to a BRICK WALL now since I've been repeating
this for 6 months or more, and after everyone seemly agrees logsys is
the way to roll, NOW IT IS CRITICAL TO REWRITE THE API because it uses a
macro to support subsystems.  I try not to take personal insult when
these sorts of things happen but seriously, the api has been published
for over 6 months and now it is not sufficient?  Where were these posts
6 months ago?  IMO the naysayers are a day late and a dollar short.

sigh
-steve



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2008-06-28  3:50 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-25  4:25 [Cluster-devel] Cluster Project branch, master, updated. cluster-2.99.05-9-g95a5c6b fabbione
2008-06-25 14:43 ` [Cluster-devel] logsys in fenced David Teigland
2008-06-25 14:53   ` Christine Caulfield
2008-06-25 15:55     ` David Teigland
2008-06-25 16:12   ` Steven Dake
2008-06-25 16:19   ` Fabio M. Di Nitto
2008-06-25 16:50     ` David Teigland
2008-06-25 17:04       ` Fabio M. Di Nitto
2008-06-25 17:30         ` David Teigland
  -- strict thread matches above, loose matches on Subject: below --
2008-06-25 21:21 David Teigland
2008-06-26  3:48 ` Fabio M. Di Nitto
2008-06-26 14:05   ` David Teigland
2008-06-27  3:45     ` Fabio M. Di Nitto
2008-06-27 15:12       ` Fabio M. Di Nitto
2008-06-26 21:43 ` David Teigland
2008-06-27 15:06   ` David Teigland
2008-06-27 15:16     ` Fabio M. Di Nitto
2008-06-28  3:27     ` Joel Becker
2008-06-28  3:50       ` Steven Dake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).