summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sentinel.conf8
-rw-r--r--src/sentinel.c28
-rw-r--r--tests/sentinel/tests/01-conf-update.tcl8
3 files changed, 43 insertions, 1 deletions
diff --git a/sentinel.conf b/sentinel.conf
index bba9b92c2..0f0265c97 100644
--- a/sentinel.conf
+++ b/sentinel.conf
@@ -19,6 +19,14 @@ daemonize no
# location here.
pidfile /var/run/redis-sentinel.pid
+# Specify the server verbosity level.
+# This can be one of:
+# debug (a lot of information, useful for development/testing)
+# verbose (many rarely useful info, but not a mess like the debug level)
+# notice (moderately verbose, what you want in production probably)
+# warning (only very important / critical messages are logged)
+loglevel notice
+
# Specify the log file name. Also the empty string can be used to force
# Sentinel to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
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);
}
diff --git a/tests/sentinel/tests/01-conf-update.tcl b/tests/sentinel/tests/01-conf-update.tcl
index 5dca55601..888e6c9b3 100644
--- a/tests/sentinel/tests/01-conf-update.tcl
+++ b/tests/sentinel/tests/01-conf-update.tcl
@@ -37,3 +37,11 @@ test "After Sentinel 1 is restarted, its config gets updated" {
test "New master [join $addr {:}] role matches" {
assert {[RI $master_id role] eq {master}}
}
+
+test "Update log level" {
+ set current_loglevel [S 0 SENTINEL CONFIG GET loglevel]
+ assert {[lindex $current_loglevel 1] == {notice}}
+ S 0 SENTINEL CONFIG SET loglevel warning
+ set updated_loglevel [S 0 SENTINEL CONFIG GET loglevel]
+ assert {[lindex $updated_loglevel 1] == {warning}}
+}