summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2016-11-30 16:46:19 +1100
committerMartin Schwenke <martins@samba.org>2016-12-05 08:09:22 +0100
commit28b6a90a159f78abb37dba04ee4f178cc5dde647 (patch)
treef1eb558d951a73d2034623956c4087de6d7fbe36 /ctdb
parent02aa65cede61da7d53087bc3c836c6c101d5bf36 (diff)
downloadsamba-28b6a90a159f78abb37dba04ee4f178cc5dde647.tar.gz
ctdb-daemon: Consolidate initialization of logging and debug level
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/include/ctdb_private.h3
-rw-r--r--ctdb/server/ctdb_logging.c5
-rw-r--r--ctdb/server/ctdbd.c16
3 files changed, 11 insertions, 13 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index cecc36fd156..0a68dae427b 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -676,7 +676,8 @@ struct lock_request *ctdb_lock_db(TALLOC_CTX *mem_ctx,
extern const char *debug_extra;
-bool ctdb_logging_init(TALLOC_CTX *mem_ctx, const char *logging);
+bool ctdb_logging_init(TALLOC_CTX *mem_ctx, const char *logging,
+ const char *debug_level);
struct ctdb_log_state *ctdb_vfork_with_logging(TALLOC_CTX *mem_ctx,
struct ctdb_context *ctdb,
diff --git a/ctdb/server/ctdb_logging.c b/ctdb/server/ctdb_logging.c
index 198718029d2..fdf0673308b 100644
--- a/ctdb/server/ctdb_logging.c
+++ b/ctdb/server/ctdb_logging.c
@@ -52,7 +52,8 @@ struct ctdb_log_state {
static struct ctdb_log_state *log_state;
/* Initialise logging */
-bool ctdb_logging_init(TALLOC_CTX *mem_ctx, const char *logging)
+bool ctdb_logging_init(TALLOC_CTX *mem_ctx, const char *logging,
+ const char *debug_level)
{
int ret;
@@ -61,7 +62,7 @@ bool ctdb_logging_init(TALLOC_CTX *mem_ctx, const char *logging)
return false;
}
- ret = logging_init(mem_ctx, logging, NULL, "ctdbd");
+ ret = logging_init(mem_ctx, logging, debug_level, "ctdbd");
if (ret != 0) {
return false;
}
diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c
index b054b7fb929..58f402708fa 100644
--- a/ctdb/server/ctdbd.c
+++ b/ctdb/server/ctdbd.c
@@ -66,6 +66,7 @@ static struct {
int torture;
} options = {
.socket = CTDB_RUNDIR "/ctdbd.socket",
+ .debuglevel = "NOTICE",
.nlist = NULL,
.public_address_list = NULL,
.transport = "tcp",
@@ -154,7 +155,6 @@ int main(int argc, const char *argv[])
const char **extra_argv;
poptContext pc;
struct tevent_context *ev;
- int log_level;
pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
@@ -198,12 +198,12 @@ int main(int argc, const char *argv[])
ctdb_set_flags(ctdb, CTDB_FLAG_TORTURE);
}
- /* Set the debug level */
- if (debug_level_parse(options.debuglevel, &log_level)) {
- DEBUGLEVEL = log_level;
- } else {
- DEBUGLEVEL = DEBUG_NOTICE;
+ /* Initialize logging and set the debug level */
+ if (!ctdb_logging_init(ctdb, options.logging, options.debuglevel)) {
+ exit(1);
}
+ setenv("CTDB_LOGGING", options.logging, 1);
+ setenv("CTDB_DEBUGLEVEL", debug_level_to_string(DEBUGLEVEL), 1);
setenv("CTDB_SOCKET", options.socket, 1);
ret = ctdb_set_socketname(ctdb, options.socket);
@@ -217,10 +217,6 @@ int main(int argc, const char *argv[])
script_log_level = options.script_log_level;
- if (!ctdb_logging_init(ctdb, options.logging)) {
- exit(1);
- }
-
DEBUG(DEBUG_NOTICE,("CTDB starting on node\n"));
gettimeofday(&ctdb->ctdbd_start_time, NULL);