Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Generate log directory, if it does not exist #403

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
2 changes: 1 addition & 1 deletion conf/nebula-metad.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
--pid_file=pids/nebula-metad.pid

########## logging ##########
# The directory to host logging files, which must already exists
# The directory to host logging files
--log_dir=logs
# Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively
--minloglevel=0
Expand Down
2 changes: 1 addition & 1 deletion conf/nebula-metad.conf.production
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
--pid_file=pids/nebula-metad.pid

########## logging ##########
# The directory to host logging files, which must already exists
# The directory to host logging files
--log_dir=logs
# Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively
--minloglevel=0
Expand Down
2 changes: 1 addition & 1 deletion conf/nebula-storaged-listener.conf.production
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
--pid_file=pids_listener/nebula-storaged.pid

########## logging ##########
# The directory to host logging files, which must already exists
# The directory to host logging files
--log_dir=logs_listener
# Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively
--minloglevel=0
Expand Down
2 changes: 1 addition & 1 deletion conf/nebula-storaged.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
--pid_file=pids/nebula-storaged.pid

########## logging ##########
# The directory to host logging files, which must already exists
# The directory to host logging files
--log_dir=logs
# Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively
--minloglevel=0
Expand Down
2 changes: 1 addition & 1 deletion conf/nebula-storaged.conf.production
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
--pid_file=pids/nebula-storaged.pid

########## logging ##########
# The directory to host logging files, which must already exists
# The directory to host logging files
--log_dir=logs
# Log level, 0, 1, 2, 3 for INFO, WARNING, ERROR, FATAL respectively
--minloglevel=0
Expand Down
10 changes: 10 additions & 0 deletions src/daemons/SetupLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "common/base/Base.h"
#include "common/base/Status.h"
#include "common/fs/FileUtils.h"

DECLARE_string(log_dir);

Expand All @@ -14,8 +15,17 @@ DEFINE_string(stdout_log_file, "stdout.log", "Destination filename of stdout");
DEFINE_string(stderr_log_file, "stderr.log", "Destination filename of stderr");

using nebula::Status;
using nebula::fs::FileUtils;

Status setupLogging() {
// If the log directory does not exist, try to create
if (!FileUtils::exist(FLAGS_log_dir)) {
if (!FileUtils::makeDir(FLAGS_log_dir)) {
return Status::Error(
"Failed to create log directory `%s'", FLAGS_log_dir.c_str());
}
}

if (!FLAGS_redirect_stdout) {
return Status::OK();
}
Expand Down