master - rgmanager: make clulog build even though it's incomplete

Lon Hohberger lon@fedoraproject.org
Fri Sep 26 18:39:00 GMT 2008


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=c0bd145a68448c27ac55cf8059e2fddcef9d9a3b
Commit:        c0bd145a68448c27ac55cf8059e2fddcef9d9a3b
Parent:        d60dd0e1b04904906176d2a4fd96d05144a3f4c8
Author:        Lon Hohberger <lhh@redhat.com>
AuthorDate:    Fri Sep 26 14:37:05 2008 -0400
Committer:     Lon Hohberger <lhh@redhat.com>
CommitterDate: Fri Sep 26 14:38:04 2008 -0400

rgmanager: make clulog build even though it's incomplete

---
 rgmanager/src/resources/ocf-shellfuncs |    3 +-
 rgmanager/src/utils/Makefile           |    4 +-
 rgmanager/src/utils/clulog.c           |   90 ++++++++++----------------------
 3 files changed, 31 insertions(+), 66 deletions(-)

diff --git a/rgmanager/src/resources/ocf-shellfuncs b/rgmanager/src/resources/ocf-shellfuncs
index e61d170..f8226cb 100644
--- a/rgmanager/src/resources/ocf-shellfuncs
+++ b/rgmanager/src/resources/ocf-shellfuncs
@@ -159,8 +159,7 @@ ocf_log() {
 	if [ -z "`which clulog 2> /dev/null`" ]; then
 		return 0
 	fi
-	clulog -p $__LOG_PID -n $__LOG_NAME \
-		-s $__OCF_PRIO_N "$__OCF_MSG"
+	clulog -s $__OCF_PRIO_N "$__OCF_MSG"
 }
 
 __ocf_set_defaults "$@"
diff --git a/rgmanager/src/utils/Makefile b/rgmanager/src/utils/Makefile
index bcf0832..b6c41f8 100644
--- a/rgmanager/src/utils/Makefile
+++ b/rgmanager/src/utils/Makefile
@@ -2,7 +2,7 @@ TARGET1= clubufflush
 TARGET2= clufindhostname
 TARGET3= clustat
 TARGET4= clusvcadm
-TARGET5= #clulog
+TARGET5= clulog
 TARGET6= clunfslock
 
 SBINDIRT=$(TARGET1) $(TARGET2) $(TARGET3) $(TARGET4) $(TARGET5) $(TARGET6)
@@ -52,7 +52,7 @@ ${TARGET4}: ${OBJS4} ${LDDEPS}
 	$(CC) -o $@ $^ $(CMAN_LDFLAGS) $(PTHREAD_LDFLAGS) $(LDFLAGS)
 
 ${TARGET5}: ${OBJS5} ${LDDEPS}
-	$(CC) -o $@ $^ $(CCS_LDFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $^ $(CCS_LDFLAGS) $(CMAN_LDFLAGS) $(LDFLAGS)
 
 ${TARGET6}:
 	cp $(S)/${TARGET6}.sh ${TARGET6}
diff --git a/rgmanager/src/utils/clulog.c b/rgmanager/src/utils/clulog.c
index a40b699..48433d8 100644
--- a/rgmanager/src/utils/clulog.c
+++ b/rgmanager/src/utils/clulog.c
@@ -8,82 +8,48 @@
 #include <errno.h>
 #include <getopt.h>
 #include <string.h>
-#include <sys/syslog.h>
 #include <corosync/engine/logsys.h>
 #include <ccs.h>
-
-int configure_logging(int);
-
-#define MAX_TOKENLEN   64
+#include <logging.h>
 
 void
 usage(char *progname)
 {
-    fprintf(stdout, "%s -s severity [-f facility] [-l priority_filter] [-n program name] \n"
-	    "\t\t [-p pid] \"message text\"\n", progname);
-    exit(0);
+	fprintf(stdout, "%s -s severity \"message text\"\n", progname);
+	exit(0);
 }
 
 
 int
 main(int argc, char **argv)
 {
-    int  opt;
-    int  severity = 7,
-	 cmdline_loglevel = 0;/* set if we should not use the config file val*/
-    char *logmsg;
-    int  pid = 0;
-    char *progname = NULL;
-    int result;
-    size_t len;
-
-    if (argc < 4)
-	usage(argv[0]);
-
-    while ((opt = getopt(argc, argv, "f:l:s:hp:n:")) != -1) {
-	switch (opt) {
-	case 'l':
-	    clu_set_loglevel(atoi(optarg));
-	    cmdline_loglevel = 1;
-	case 'f':
-	    clu_set_facility(optarg);
-	    break;
-	case 's':
-	    severity = atoi(optarg);
-	    break;
-	case 'p':
-	    pid = atoi(optarg);
-	    break;
-	case 'n':
-	    progname = strdup(optarg);
-	    break;
-	case 'h':
-	    usage(argv[0]);
-	default:
-	    usage(argv[0]);
+	int opt, ccsfd;
+	int severity = -1;
+
+	char *logmsg = argv[argc-1];
+
+	while ((opt = getopt(argc, argv, "s:h")) != EOF) {
+		switch(opt) {
+		case 's':
+			severity = atoi(optarg);
+			break;
+		case 'h':
+		default:
+			usage(argv[0]);
+			break;
+		}
 	}
-    }
 
-    /* Add two bytes for linefeed and NULL terminator */
-    len = strlen(argv[argc-1]) + 2;
-    logmsg = (char*)malloc(strlen(argv[argc-1])+2);
-    if (logmsg == NULL) {
-        fprintf(stderr,
-            "log_printf: malloc fail err=%d\n", errno);
-        exit(0);
-    }
+	if (severity < 0)
+		severity = LOG_INFO;
+
+	init_logging();
+	ccsfd = ccs_connect();
+	setup_logging(ccsfd);
+	ccs_disconnect(ccsfd);
 
-    snprintf(logmsg, len, "%s\n", argv[argc-1]);
+	log_printf(severity, "%s", logmsg);
 
-    if (!cmdline_loglevel) {
-	/*
-	 * Let's see what loglevel the SM is running at.
-	 * If ccsd's not available, use default.
-	 */
-    	if (configure_logging(-1) < 0)
-		clu_set_loglevel(LOGLEVEL_DFLT);
-    }
-    result = log_printf_pid(severity, pid, progname, logmsg);
-    free(progname);
-    return(result);
+	close_logging();
+	return 0;
 }



More information about the Cluster-cvs mailing list