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

option to enable build-in log rotation enabled leveraging glog #5688 #5958

Merged
merged 1 commit into from
Oct 18, 2024
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
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
Loading