Skip to content

Commit

Permalink
option to enable build-in log rotation enabled leveraging glog #5688
Browse files Browse the repository at this point in the history
  • Loading branch information
E2ern1ty committed Oct 12, 2024
1 parent 831c174 commit 3b83538
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions conf/nebula-graphd.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
--stderrthreshold=3
# wether logging files' name contain time stamp.
--timestamp_in_logfile_name=true
# use max_log_size or log_clean_days to control the log file size and log file clean days. Set log_clean_days to 0 to disable log file cleaning.
--log_clean_days=0

########## query ##########
# Whether to treat partial success as an error.
# This flag is only used for Read-only access, and Modify access always treats partial success as an error.
Expand Down
2 changes: 2 additions & 0 deletions conf/nebula-metad.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
--stderrthreshold=3
# wether logging files' name contain time stamp, If Using logrotate to rotate logging files, than should set it to true.
--timestamp_in_logfile_name=true
# use max_log_size or log_clean_days to control the log file size and log file clean days. Set log_clean_days to 0 to disable log file cleaning.
--log_clean_days=0

########## networking ##########
# Comma separated Meta Server addresses
Expand Down
2 changes: 2 additions & 0 deletions conf/nebula-standalone.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
--stderr_log_file=standalone-stderr.log
# Copy log messages at or above this level to stderr in addition to logfiles. The numbers of severity levels INFO, WARNING, ERROR, and FATAL are 0, 1, 2, and 3, respectively.
--stderrthreshold=3
# use max_log_size or log_clean_days to control the log file size and log file clean days. Set log_clean_days to 0 to disable log file cleaning.
--log_clean_days=0

########## query ##########
# Whether to treat partial success as an error.
Expand Down
2 changes: 2 additions & 0 deletions conf/nebula-storaged-listener.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
--stderrthreshold=3
# Wether logging files' name contain timestamp.
--timestamp_in_logfile_name=true
# use max_log_size or log_clean_days to control the log file size and log file clean days. Set log_clean_days to 0 to disable log file cleaning.
--log_clean_days=0

########## networking ##########
# Meta server address
Expand Down
2 changes: 2 additions & 0 deletions conf/nebula-storaged.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
--stderrthreshold=3
# Wether logging files' name contain time stamp.
--timestamp_in_logfile_name=true
# use max_log_size or log_clean_days to control the log file size and log file clean days. Set log_clean_days to 0 to disable log file cleaning.
--log_clean_days=0

########## networking ##########
# Comma separated Meta server addresses
Expand Down
5 changes: 5 additions & 0 deletions src/daemons/SetupLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ DECLARE_string(log_dir);
DEFINE_bool(redirect_stdout, true, "Whether to redirect stdout and stderr to separate files");
DEFINE_string(stdout_log_file, "stdout.log", "Destination filename of stdout");
DEFINE_string(stderr_log_file, "stderr.log", "Destination filename of stderr");
DEFINE_int32(log_clean_days, 7, "clean log files older than the specified days");

using nebula::Status;
using nebula::fs::FileUtils;
Expand All @@ -43,6 +44,10 @@ Status setupLogging(const std::string &exe) {
return Status::OK();
}

if (FLAGS_log_clean_days > 0) {
google::EnableLogCleaner(FLAGS_log_clean_days);
}

auto dup = [](const std::string &filename, FILE *stream) -> Status {
auto path = FLAGS_log_dir + "/" + filename;
auto fd = ::open(path.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
Expand Down

0 comments on commit 3b83538

Please sign in to comment.