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

[Cluster-devel] Cluster Project branch, master, updated. gfs-kernel_0_1_22-205-gcf4f083



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=cf4f0831a1afdc055062f1ee1ed1629e271d1302

The branch, master has been updated
       via  cf4f0831a1afdc055062f1ee1ed1629e271d1302 (commit)
      from  370f6547ab23e0f977847a1743604f0a4ffee878 (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 cf4f0831a1afdc055062f1ee1ed1629e271d1302
Author: Fabio M. Di Nitto <fdinitto redhat com>
Date:   Thu Apr 24 11:45:01 2008 +0200

    [CCS] Allow ccsd logging level and facility to be set by cluster.conf
    
    This change allow to set log_level and log_facility for the ccs subsystem
    within cluster.conf.
    
    Here is a config example:
    
    <?xml version="1.0"?>
    <cluster name="test" config_version="1">
      <ccs log_facility="local6" log_level="debug"/>
    ....
    
    Signed-off-by: Fabio M. Di Nitto <fdinitto redhat com>

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

Summary of changes:
 ccs/daemon/ccsd.c    |    2 +-
 ccs/daemon/cnx_mgr.c |    2 +
 ccs/daemon/misc.c    |   85 ++++++++++++++++++++++++++++++++++++++++++++++++++
 ccs/daemon/misc.h    |    2 +-
 ccs/include/debug.h  |    2 +
 5 files changed, 91 insertions(+), 2 deletions(-)

diff --git a/ccs/daemon/ccsd.c b/ccs/daemon/ccsd.c
index 5fd61fb..d9cc152 100644
--- a/ccs/daemon/ccsd.c
+++ b/ccs/daemon/ccsd.c
@@ -34,7 +34,7 @@
 
 #include "copyright.cf"
 
-static int debug = 0;
+int debug = 0;
 extern volatile int quorate;
 int no_manager_opt=0;
 static int exit_now=0;
diff --git a/ccs/daemon/cnx_mgr.c b/ccs/daemon/cnx_mgr.c
index 8cdc579..3e2d21e 100644
--- a/ccs/daemon/cnx_mgr.c
+++ b/ccs/daemon/cnx_mgr.c
@@ -558,6 +558,8 @@ static int process_connect(comm_header_t *ch, char *cluster_name){
       xmlFreeDoc(master_doc->od_doc);
       master_doc->od_doc = NULL;
       free(tmp_name); tmp_name = NULL;
+    } else if(set_ccs_logging(master_doc->od_doc) < 0){
+      log_printf(LOG_ERR, "Unable to set logging parameters.\n");
     } else {  /* Either the names match, or a name wasn't specified. */
       log_printf(LOG_INFO, DEFAULT_CONFIG_DIR "/" DEFAULT_CONFIG_FILE " (cluster name = %s, version = %d) found.\n",
 	      tmp_name, error);
diff --git a/ccs/daemon/misc.c b/ccs/daemon/misc.c
index 54b94ef..bfc8612 100644
--- a/ccs/daemon/misc.c
+++ b/ccs/daemon/misc.c
@@ -159,5 +159,90 @@ fail:
   return rtn;
 }
 
+/**
+ * set_ccs_logging
+ * @ldoc:
+ *
+ * Returns: -1 on failure. NULL on success.
+ */
+int set_ccs_logging(xmlDocPtr ldoc){
+  int facility = SYSLOGFACILITY, loglevel = LOG_LEVEL_INFO;
+  char *res = NULL;
+  xmlXPathObjectPtr  obj = NULL;
+  xmlXPathContextPtr ctx = NULL;
+  xmlNodePtr        node = NULL;
+
+  CCSENTER("set_ccs_logging");
+
+  ctx = xmlXPathNewContext(ldoc);
+  if(!ctx){
+    log_printf(LOG_ERR, "Error: unable to create new XPath context.\n");
+    return -1;
+  }
+
+  obj = xmlXPathEvalExpression((xmlChar *)"//cluster/ccs/@log_facility", ctx);
+  if(!obj || !obj->nodesetval || (obj->nodesetval->nodeNr != 1)){
+    log_printf(LOG_DEBUG, "Error while retrieving log_facility.\n");
+  } else {
+    node = obj->nodesetval->nodeTab[0];
+    if(node->type != XML_ATTRIBUTE_NODE){
+      log_printf(LOG_DEBUG, "Object returned is not of attribute type.\n");
+    } else {
+      if(!node->children->content || !strlen((char *)node->children->content)){
+	log_printf(LOG_DEBUG, "No content found.\n");
+      } else {
+	res = strdup((char *)node->children->content);
+	facility = logsys_facility_id_get (res);
+	if (facility < 0)
+		facility = SYSLOGFACILITY;
+
+	logsys_config_facility_set ("CCS", facility);
+	log_printf(LOG_DEBUG, "log_facility: %s (%d).\n", res, facility);
+	free(res);
+	res=NULL;
+      }
+    }
+  }
 
+  if(obj){
+    xmlXPathFreeObject(obj);
+    obj = NULL;
+  }
+
+  obj = xmlXPathEvalExpression((xmlChar *)"//cluster/ccs/@log_level", ctx);
+  if(!obj || !obj->nodesetval || (obj->nodesetval->nodeNr != 1)){
+    log_printf(LOG_DEBUG, "Error while retrieving log_level.\n");
+  } else {
+    node = obj->nodesetval->nodeTab[0];
+    if(node->type != XML_ATTRIBUTE_NODE){
+      log_printf(LOG_DEBUG, "Object returned is not of attribute type.\n");
+    } else {
+      if(!node->children->content || !strlen((char *)node->children->content)){
+	log_printf(LOG_DEBUG, "No content found.\n");
+      } else {
+	res = strdup((char *)node->children->content);
+	loglevel = atoi(res);
+	if (loglevel < 0)
+	  loglevel = LOG_LEVEL_INFO;
+
+	if (!debug)
+	  logsys_config_priority_set (loglevel);
+
+	log_printf(LOG_DEBUG, "log_level: %s (%d).\n", res, loglevel);
+	free(res);
+	res=NULL;
+      }
+    }
+  }
+
+  if(ctx){
+    xmlXPathFreeContext(ctx);
+  }
+  if(obj){
+    xmlXPathFreeObject(obj);
+  }
+
+  CCSEXIT("set_ccs_logging");
+  return 0;
+}
 
diff --git a/ccs/daemon/misc.h b/ccs/daemon/misc.h
index dcfc94f..d6cf572 100644
--- a/ccs/daemon/misc.h
+++ b/ccs/daemon/misc.h
@@ -25,6 +25,6 @@ extern open_doc_t *master_doc;
 
 char *get_cluster_name(xmlDocPtr ldoc);
 int get_doc_version(xmlDocPtr ldoc);
-
+int set_ccs_logging(xmlDocPtr ldoc);
 
 #endif /* __MISC_H__ */
diff --git a/ccs/include/debug.h b/ccs/include/debug.h
index 49af319..b3d963d 100644
--- a/ccs/include/debug.h
+++ b/ccs/include/debug.h
@@ -16,4 +16,6 @@
 #define CCSENTER(x) log_printf(LOG_DEBUG, "Entering " x "\n")
 #define CCSEXIT(x) log_printf(LOG_DEBUG, "Exiting " x "\n")
 
+extern int debug;
+
 #endif /* __DEBUG_DOT_H__ */


hooks/post-receive
--
Cluster Project


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