From 3106d74787e5bb6765b8dd1d49229e5b0c9f82b1 Mon Sep 17 00:00:00 2001 From: kanoi Date: Wed, 27 Aug 2014 15:04:09 +1000 Subject: [PATCH] ckdb - socket loglevel display only if no ID --- src/ckdb.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index 6ea93217..3c527f81 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -9192,26 +9192,35 @@ static void *socketer(__maybe_unused void *arg) send_unix_msg(sockd, reply); break; case CMD_LOGLEVEL: - oldloglevel = pi->ckp->loglevel; - loglevel = atoi(id); - LOGDEBUG("Listener received loglevel %d currently %d A", - loglevel, oldloglevel); - if (loglevel < LOG_EMERG || loglevel > LOG_DEBUG) { + if (!*id) { + LOGDEBUG("Listener received loglevel, currently %d", + oldloglevel); snprintf(reply, sizeof(reply), - "%s.%ld.ERR.invalid loglevel %d" - " - currently %d", + "%s.%ld.ok.loglevel currently %d", id, now.tv_sec, - loglevel, oldloglevel); + pi->ckp->loglevel); } else { - pi->ckp->loglevel = loglevel; - snprintf(reply, sizeof(reply), - "%s.%ld.ok.loglevel now %d - was %d", - id, now.tv_sec, - pi->ckp->loglevel, oldloglevel); + oldloglevel = pi->ckp->loglevel; + loglevel = atoi(id); + LOGDEBUG("Listener received loglevel %d currently %d A", + loglevel, oldloglevel); + if (loglevel < LOG_EMERG || loglevel > LOG_DEBUG) { + snprintf(reply, sizeof(reply), + "%s.%ld.ERR.invalid loglevel %d" + " - currently %d", + id, now.tv_sec, + loglevel, oldloglevel); + } else { + pi->ckp->loglevel = loglevel; + snprintf(reply, sizeof(reply), + "%s.%ld.ok.loglevel now %d - was %d", + id, now.tv_sec, + pi->ckp->loglevel, oldloglevel); + } + // Do this twice since the loglevel may have changed + LOGDEBUG("Listener received loglevel %d currently %d B", + loglevel, oldloglevel); } - // Do this twice since the loglevel may have changed - LOGDEBUG("Listener received loglevel %d currently %d B", - loglevel, oldloglevel); send_unix_msg(sockd, reply); break; // Always process immediately: