set up a handler to catch and log debug messages from the tevent layer
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 22 Sep 2010 00:59:01 +0000 (10:59 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 27 Sep 2010 22:30:26 +0000 (08:30 +1000)
include/ctdb_private.h
server/ctdb_daemon.c
server/ctdb_logging.c
server/ctdbd.c

index 8ceae20..cd6aeec 100644 (file)
@@ -1337,4 +1337,6 @@ int verify_remote_ip_allocation(struct ctdb_context *ctdb,
 int update_ip_assignment_tree(struct ctdb_context *ctdb,
                                struct ctdb_public_ip *ip);
 
+int ctdb_init_tevent_logging(struct ctdb_context *ctdb);
+
 #endif
index 5d73b0d..418d91e 100644 (file)
@@ -774,6 +774,11 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog)
 
        ctdb->ev = event_context_init(NULL);
        tevent_loop_allow_nesting(ctdb->ev);
+       ret = ctdb_init_tevent_logging(ctdb);
+       if (ret != 0) {
+               DEBUG(DEBUG_ALERT,("Failed to initialize TEVENT logging\n"));
+               exit(1);
+       }
 
        ctdb_set_child_logging(ctdb);
 
index 2cc0559..7e5367e 100644 (file)
@@ -547,6 +547,46 @@ int ctdb_set_child_logging(struct ctdb_context *ctdb)
 }
 
 
+/*
+ * set up a log handler to catch logging from TEVENT
+ */
+static void ctdb_tevent_logging(void *private_data,
+                               enum tevent_debug_level level,
+                               const char *fmt,
+                               va_list ap)
+{
+       enum debug_level lvl = DEBUG_EMERG;
+
+       switch (level) {
+       case TEVENT_DEBUG_FATAL:
+               lvl = DEBUG_EMERG;
+               break;
+       case TEVENT_DEBUG_ERROR:
+               lvl = DEBUG_ERR;
+               break;
+       case TEVENT_DEBUG_WARNING:
+               lvl = DEBUG_WARNING;
+               break;
+       case TEVENT_DEBUG_TRACE:
+               lvl = DEBUG_DEBUG;
+               break;
+       }
+
+       if (lvl <= LogLevel) {
+               this_log_level = lvl;
+               do_debug_v(fmt, ap);
+       }
+}
+
+int ctdb_init_tevent_logging(struct ctdb_context *ctdb)
+{
+       int ret;
+
+       ret = tevent_set_debug(ctdb->ev,
+                       ctdb_tevent_logging,
+                       ctdb);
+       return ret;
+}
 
 
        
index 89b9af1..674ebab 100644 (file)
@@ -195,6 +195,7 @@ int main(int argc, const char *argv[])
        }
 
        DEBUG(DEBUG_NOTICE,("Starting CTDB daemon\n"));
+
        gettimeofday(&ctdb->ctdbd_start_time, NULL);
        gettimeofday(&ctdb->last_recovery_started, NULL);
        gettimeofday(&ctdb->last_recovery_finished, NULL);