Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support change log-level in runtime #1611

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/config/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions tests/cppunit/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down