Skip to content

Commit

Permalink
Glog 0.7.0 errors (#11)
Browse files Browse the repository at this point in the history
* Fix build errors related to GLOG

* Format code

* Fix
  • Loading branch information
torwig authored Feb 18, 2024
1 parent d874f20 commit 22497c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/cli/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<google::LogSeverity>(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::minutes>(std::chrono::hours(24) * config->log_retention_days);
google::EnableLogCleaner(minutes);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/config/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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::minutes>(std::chrono::hours(24) * log_retention_days);
google::EnableLogCleaner(minutes);
} else {
google::DisableLogCleaner();
}
Expand Down

0 comments on commit 22497c4

Please sign in to comment.