From fdb4c02f595fa207310a9a48da3fefd653fa9e4b Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Wed, 22 Sep 2010 10:59:01 +1000 Subject: [PATCH] set up a handler to catch and log debug messages from the tevent layer --- include/ctdb_private.h | 2 ++ server/ctdb_daemon.c | 5 +++++ server/ctdb_logging.c | 40 ++++++++++++++++++++++++++++++++++++++++ server/ctdbd.c | 1 + 4 files changed, 48 insertions(+) diff --git a/include/ctdb_private.h b/include/ctdb_private.h index 8ceae204..cd6aeec1 100644 --- a/include/ctdb_private.h +++ b/include/ctdb_private.h @@ -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 diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c index 5d73b0d5..418d91ed 100644 --- a/server/ctdb_daemon.c +++ b/server/ctdb_daemon.c @@ -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); diff --git a/server/ctdb_logging.c b/server/ctdb_logging.c index 2cc05593..7e5367ea 100644 --- a/server/ctdb_logging.c +++ b/server/ctdb_logging.c @@ -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; +} diff --git a/server/ctdbd.c b/server/ctdbd.c index 89b9af17..674ebab6 100644 --- a/server/ctdbd.c +++ b/server/ctdbd.c @@ -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); -- 2.34.1