diff --git a/src/cli/main.cc b/src/cli/main.cc index c03923e7893..1fe9accbb23 100644 --- a/src/cli/main.cc +++ b/src/cli/main.cc @@ -32,6 +32,7 @@ #include "config.h" #include "daemon_util.h" +#include "glog/log_severity.h" #include "io_util.h" #include "pid_util.h" #include "scope_exit.h" @@ -103,14 +104,16 @@ static void InitGoogleLog(const Config *config) { if (util::EqualICase(config->log_dir, "stdout")) { for (int level = google::INFO; level <= google::FATAL; level++) { - google::SetLogDestination(level, ""); + google::SetLogDestination(static_cast(level), ""); } FLAGS_stderrthreshold = google::ERROR; FLAGS_logtostdout = true; } else { FLAGS_log_dir = config->log_dir + "/"; if (config->log_retention_days != -1) { - google::EnableLogCleaner(config->log_retention_days); + auto minutes = + std::chrono::duration_cast(std::chrono::hours(24) * config->log_retention_days); + google::EnableLogCleaner(minutes); } } } diff --git a/src/config/config.cc b/src/config/config.cc index db7ee712a99..467523b22b8 100644 --- a/src/config/config.cc +++ b/src/config/config.cc @@ -541,7 +541,9 @@ void Config::initFieldCallback() { } if (log_retention_days != -1) { - google::EnableLogCleaner(log_retention_days); + auto minutes = + std::chrono::duration_cast(std::chrono::hours(24) * log_retention_days); + google::EnableLogCleaner(minutes); } else { google::DisableLogCleaner(); }