summaryrefslogtreecommitdiff
path: root/src/sentinel.c
diff options
context:
space:
mode:
authorWen Hui <wen.hui.ware@gmail.com>2022-11-20 05:03:00 -0500
committerGitHub <noreply@github.com>2022-11-20 12:03:00 +0200
commit2f411770c85ddfd226c02819c0f98a3f5a7854ac (patch)
treed921027c8667b2543c1b9de747c4e838adbe8f03 /src/sentinel.c
parent203b12e41ff7981f0fae5b23819f072d61594813 (diff)
downloadredis-2f411770c85ddfd226c02819c0f98a3f5a7854ac.tar.gz
Add CONFIG SET and GET loglevel feature in Sentinel (#11214)
Till now Sentinel allowed modifying the log level in the config file, but not at runtime. this makes it possible to tune the log level at runtime
Diffstat (limited to 'src/sentinel.c')
-rw-r--r--src/sentinel.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/sentinel.c b/src/sentinel.c
index 48369df99..595a12fea 100644
--- a/src/sentinel.c
+++ b/src/sentinel.c
@@ -3182,7 +3182,17 @@ void sentinelSendPeriodicCommands(sentinelRedisInstance *ri) {
/* =========================== SENTINEL command ============================= */
-/* SENTINEL CONFIG SET <option> */
+const char* getLogLevel() {
+ switch (server.verbosity) {
+ case LL_DEBUG: return "debug";
+ case LL_VERBOSE: return "verbose";
+ case LL_NOTICE: return "notice";
+ case LL_WARNING: return "warning";
+ }
+ return "unknown";
+}
+
+/* SENTINEL CONFIG SET <option> <value>*/
void sentinelConfigSetCommand(client *c) {
robj *o = c->argv[3];
robj *val = c->argv[4];
@@ -3213,6 +3223,17 @@ void sentinelConfigSetCommand(client *c) {
sentinel.sentinel_auth_pass = sdslen(val->ptr) == 0 ?
NULL : sdsdup(val->ptr);
drop_conns = 1;
+ } else if (!strcasecmp(o->ptr, "loglevel")) {
+ if (!strcasecmp(val->ptr, "debug"))
+ server.verbosity = LL_DEBUG;
+ else if (!strcasecmp(val->ptr, "verbose"))
+ server.verbosity = LL_VERBOSE;
+ else if (!strcasecmp(val->ptr, "notice"))
+ server.verbosity = LL_NOTICE;
+ else if (!strcasecmp(val->ptr, "warning"))
+ server.verbosity = LL_WARNING;
+ else
+ goto badfmt;
} else {
addReplyErrorFormat(c, "Invalid argument '%s' to SENTINEL CONFIG SET",
(char *) o->ptr);
@@ -3275,6 +3296,11 @@ void sentinelConfigGetCommand(client *c) {
matches++;
}
+ if (stringmatch(pattern, "loglevel", 1)) {
+ addReplyBulkCString(c, "loglevel");
+ addReplyBulkCString(c, getLogLevel());
+ matches++;
+ }
setDeferredMapLen(c, replylen, matches);
}