This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cluster: the tag rgmanager_2_0_49 has been created


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=fd47fd5c3395467b517090f11d676bc52dba77ab
Commit:        fd47fd5c3395467b517090f11d676bc52dba77ab
Parent:        a4502a9c90a518fc121de2a3d62ae36a44b92468
Author:        Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate:    Wed May 20 15:22:56 2009 +0200
Committer:     Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Wed May 20 15:22:56 2009 +0200

cman: fix logging config

forward port ed02ac5f4275e1a8e26c8639880e928b747b44f1
from stable3 to master

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
 cman/config/cman-preconfig.c     |  103 ++++++++++++++++++++++----------------
 cman/services/cman/lib/libcman.h |   14 ++----
 2 files changed, 63 insertions(+), 54 deletions(-)

diff --git a/cman/config/cman-preconfig.c b/cman/config/cman-preconfig.c
index e4facb1..91a914b 100644
--- a/cman/config/cman-preconfig.c
+++ b/cman/config/cman-preconfig.c
@@ -26,7 +26,7 @@
 
 #define MAX_PATH_LEN PATH_MAX
 
-static unsigned int debug_mask;
+static unsigned int debug;
 static int cmanpre_readconfig(struct objdb_iface_ver0 *objdb, const char **error_string);
 static int cmanpre_reloadconfig(struct objdb_iface_ver0 *objdb, int flush, const char **error_string);
 
@@ -203,25 +203,17 @@ static unsigned int find_cman_logger(struct objdb_iface_ver0 *objdb, hdb_handle_
 	char *str;
 
 	objdb->object_find_create(object_handle, "logger_subsys", strlen("logger_subsys"), &find_handle);
-	while (!objdb->object_find_next(object_handle, &subsys_handle)) {
-
-		if (objdb_get_string(objdb, subsys_handle, "subsys", &str)) {
-			continue;
+	while (!objdb->object_find_next(find_handle, &subsys_handle)) {
+		if (!objdb_get_string(objdb, subsys_handle, "subsys", &str)) {
+			if (strncmp(str, CMAN_NAME, 4) == 0) {
+				objdb->object_find_destroy(find_handle);
+				return subsys_handle;
+			}
 		}
-		if (strcmp(str, CMAN_NAME) == 0)
-			return subsys_handle;
 	}
 	objdb->object_find_destroy(find_handle);
 
-	/* We can't find it ... create one */
-	if (objdb->object_create(object_handle, &subsys_handle,
-				    "logger_subsys", strlen("logger_subsys")) == 0) {
-
-		objdb->object_key_create(subsys_handle, "subsys", strlen("subsys"),
-					    CMAN_NAME, strlen(CMAN_NAME)+1);
-	}
-
-	return subsys_handle;
+	return -1;
 
 }
 
@@ -523,7 +515,9 @@ static int get_env_overrides()
 		node_votes = 1;
 	}
 	if (getenv("CMAN_DEBUGLOG")) {
-		debug_mask = atoi(getenv("CMAN_DEBUGLOG"));
+		debug = atoi(getenv("CMAN_DEBUGLOG"));
+		if (debug > 0)
+			debug = 1;
 	}
 
 	return 0;
@@ -663,9 +657,9 @@ out:
 /* These are basically cman overrides to the totem config bits */
 static void add_cman_overrides(struct objdb_iface_ver0 *objdb)
 {
-	hdb_handle_t logger_object_handle;
 	char *logstr;
 	char *logfacility;
+	char *loglevel;
 	hdb_handle_t object_handle;
 	hdb_handle_t find_handle;
 	char tmp[256];
@@ -764,16 +758,17 @@ static void add_cman_overrides(struct objdb_iface_ver0 *objdb)
 	objdb->object_find_destroy(find_handle);
 
 	logfacility = facility_name_get(SYSLOGFACILITY);
+	loglevel = priority_name_get(SYSLOGLEVEL);
 
-	logger_object_handle = find_cman_logger(objdb, object_handle);
-
-	if (objdb_get_string(objdb, object_handle, "syslog_facility", &logstr)) {
-		objdb->object_key_create(object_handle, "syslog_facility", strlen("syslog_facility"),
-					    logfacility, strlen(logfacility)+1);
+	/* enable timestamps on logging */
+	if (objdb_get_string(objdb, object_handle, "timestamp", &logstr)) {
+		objdb->object_key_create(object_handle, "timestamp", strlen("timestamp"),
+					    "on", strlen("on")+1);
 	}
 
-	if (objdb_get_string(objdb, object_handle, "to_file", &logstr)) {
-		objdb->object_key_create(object_handle, "to_file", strlen("to_file"),
+	/* configure logfile */
+	if (objdb_get_string(objdb, object_handle, "to_logfile", &logstr)) {
+		objdb->object_key_create(object_handle, "to_logfile", strlen("to_logfile"),
 					    "yes", strlen("yes")+1);
 	}
 
@@ -782,27 +777,53 @@ static void add_cman_overrides(struct objdb_iface_ver0 *objdb)
 					    LOGDIR "/corosync.log", strlen(LOGDIR "/corosync.log")+1);
 	}
 
-	if (objdb_get_string(objdb, object_handle, "timestamp", &logstr)) {
-		objdb->object_key_create(object_handle, "timestamp", strlen("timestamp"),
-					    "on", strlen("on")+1);
+	if (objdb_get_string(objdb, object_handle, "logfile_priority", &logstr)) {
+		objdb->object_key_create(object_handle, "logfile_priority", strlen("logfile_priority"),
+					    loglevel, strlen(loglevel)+1);
 	}
 
-	if (debug_mask) {
-		objdb->object_key_create(object_handle, "to_stderr", strlen("to_stderr"),
+	/* syslog */
+	if (objdb_get_string(objdb, object_handle, "to_syslog", &logstr)) {
+		objdb->object_key_create(object_handle, "to_syslog", strlen("to_syslog"),
 					    "yes", strlen("yes")+1);
-		objdb->object_key_create(logger_object_handle, "debug", strlen("debug"),
-					    "on", strlen("on")+1);
-		objdb->object_key_create(logger_object_handle, "syslog_level", strlen("syslog_level"),
-					    "debug", strlen("debug")+1);
+	}
 
+	if (objdb_get_string(objdb, object_handle, "syslog_facility", &logstr)) {
+		objdb->object_key_create(object_handle, "syslog_facility", strlen("syslog_facility"),
+					    logfacility, strlen(logfacility)+1);
 	}
-	else {
-		char *loglevel;
-		loglevel = priority_name_get(SYSLOGLEVEL);
-		objdb->object_key_create(logger_object_handle, "syslog_level", strlen("syslog_level"),
+
+	if (objdb_get_string(objdb, object_handle, "syslog_priority", &logstr)) {
+		objdb->object_key_create(object_handle, "syslog_priority", strlen("syslog_priority"),
 					    loglevel, strlen(loglevel)+1);
 	}
 
+	if (!debug) {
+		hdb_handle_t logger_object_handle;
+
+		if (!objdb_get_string(objdb, object_handle, "debug", &logstr)) {
+			if (!strncmp(logstr, "on", 2)) {
+				debug=1;
+			}
+		}
+
+		logger_object_handle = find_cman_logger(objdb, object_handle);
+		if (logger_object_handle > -1) {
+			if (!objdb_get_string(objdb, logger_object_handle, "debug", &logstr)) {
+				if (!strncmp(logstr, "on", 2)) {
+					debug=1;
+				}
+				if (!strncmp(logstr, "off", 3)) {
+					debug=0;
+				}
+			}
+		}
+	}
+
+	if (debug) {
+		objdb->object_key_create(object_handle, "to_stderr", strlen("to_stderr"),
+					    "yes", strlen("yes")+1);
+	}
 
 	/* Make sure we allow connections from user/group "ais" */
 	objdb->object_find_create(OBJECT_PARENT_HANDLE, "aisexec", strlen("aisexec"), &find_handle);
@@ -825,12 +846,6 @@ static void add_cman_overrides(struct objdb_iface_ver0 *objdb)
 
 		objdb->object_key_create(object_handle, "cluster_id", strlen("cluster_id"),
 					 str, strlen(str) + 1);
-
-		if (debug_mask) {
-			sprintf(str, "%d", debug_mask);
-			objdb->object_key_create(object_handle, "debug_mask", strlen("debug_mask"),
-						 str, strlen(str) + 1);
-		}
 	}
 	objdb->object_find_destroy(find_handle);
 
diff --git a/cman/services/cman/lib/libcman.h b/cman/services/cman/lib/libcman.h
index 404af07..3489025 100644
--- a/cman/services/cman/lib/libcman.h
+++ b/cman/services/cman/lib/libcman.h
@@ -408,17 +408,11 @@ int cman_get_quorum_device(cman_handle_t handle, struct cman_qdev_info *info);
  */
 int cman_set_dirty(cman_handle_t handle);
 
-
 /*
- * Changes the debug logging level inside cman.
- * subsystems is a bitmask of:
+ * From STABLE3 branch this call tells corosync to execute:
+ * logsys_config_debug_set(CMAN_NAME, value);
+ * and debugging for all CMAN subsystems is on.
  */
-#define CMAN_DEBUGLOG_NONE       0
-#define CMAN_DEBUGLOG_BARRIER    2
-#define CMAN_DEBUGLOG_MEMBERSHIP 4
-#define CMAN_DEBUGLOG_DAEMON     8
-#define CMAN_DEBUGLOG_AIS       16
-
-int cman_set_debuglog(cman_handle_t handle, int subsystems);
+int cman_set_debuglog(cman_handle_t handle, int value);
 
 #endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]