[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] logsys in fenced



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.

>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

>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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]