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 8ceae204d611d2cc3dab38944f02907a80c2a184..cd6aeec1c44d73cb0b26e73cd49886fc242741db 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 5d73b0d5d9b99a21dba6cc7cb3246b99949f6a08..418d91ed70efee7dc5fd42da14cd3bb97d23ee20 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 2cc055938f45d268499a5c49d0fb2eb5957cb959..7e5367eab537993df257c3cdda30c6fee0086eef 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 89b9af179bc4c78c3c4baf52b84e45040ed19a53..674ebab6978a00712d7fefdf53828c31b854862b 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);