This is an automated email from the ASF dual-hosted git repository.
binbin pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 509220c0 Support change log-level in runtime (#1611)
509220c0 is described below
commit 509220c066b3a75291be014b62646889ce031b2a
Author: Binbin <[email protected]>
AuthorDate: Wed Jul 26 16:42:24 2023 +0800
Support change log-level in runtime (#1611)
Now we support config set log-level xxx to modify log-level
in runtime.
This closes #1610.
---
src/config/config.cc | 8 +++++++-
tests/cppunit/config_test.cc | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/config/config.cc b/src/config/config.cc
index 24db89b1..08ab4c96 100644
--- a/src/config/config.cc
+++ b/src/config/config.cc
@@ -121,7 +121,7 @@ Config::Config() {
{"dir", true, new StringField(&dir, "/tmp/kvrocks")},
{"backup-dir", false, new StringField(&backup_dir, "")},
{"log-dir", true, new StringField(&log_dir, "")},
- {"log-level", true, new EnumField(&log_level, log_levels, google::INFO)},
+ {"log-level", false, new EnumField(&log_level, log_levels,
google::INFO)},
{"pidfile", true, new StringField(&pidfile, "")},
{"max-io-mb", false, new IntField(&max_io_mb, 500, 0, INT_MAX)},
{"max-bitmap-to-string-mb", false, new
IntField(&max_bitmap_to_string_mb, 16, 0, INT_MAX)},
@@ -478,6 +478,12 @@ void Config::initFieldCallback() {
if (cluster_enabled)
srv->slot_migrator->SetSequenceGapLimit(sequence_gap);
return Status::OK();
}},
+ {"log-level",
+ [this](Server *srv, const std::string &k, const std::string &v) ->
Status {
+ if (!srv) return Status::OK();
+ FLAGS_minloglevel = log_level;
+ return Status::OK();
+ }},
{"log-retention-days",
[this](Server *srv, const std::string &k, const std::string &v) ->
Status {
if (!srv) return Status::OK();
diff --git a/tests/cppunit/config_test.cc b/tests/cppunit/config_test.cc
index 9254b9b9..94c51eb9 100644
--- a/tests/cppunit/config_test.cc
+++ b/tests/cppunit/config_test.cc
@@ -36,6 +36,7 @@ TEST(Config, GetAndSet) {
auto s = config.Load(CLIOptions(path));
EXPECT_FALSE(s.IsOK());
std::map<std::string, std::string> mutable_cases = {
+ {"log-level", "info"},
{"timeout", "1000"},
{"maxclients", "2000"},
{"max-backup-to-keep", "1"},