summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-08-12 07:05:28 (GMT)
committerFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-08-12 07:05:28 (GMT)
commita94afc6807eba4ea4c3638f1aa6c3da182122f4c (patch)
treece9b65c0a04a7101cf4a57125370eaba7c542a53 /src
parentf7691955e8289e539ff60aec6e23336ad5149ff0 (diff)
parent58438d398fb61fbf96dd496ffa0d4b19d66ae60b (diff)
downloadglog-a94afc6807eba4ea4c3638f1aa6c3da182122f4c.zip
glog-a94afc6807eba4ea4c3638f1aa6c3da182122f4c.tar.gz
glog-a94afc6807eba4ea4c3638f1aa6c3da182122f4c.tar.bz2
Merge pull request #26 from theopolis/feature-mode-flag
[#23] Add logfile_mode to control logfile permissions
Diffstat (limited to 'src')
-rw-r--r--src/glog/logging.h.in3
-rw-r--r--src/logging.cc4
2 files changed, 6 insertions, 1 deletions
diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in
index d1ac52b..455bd28 100644
--- a/src/glog/logging.h.in
+++ b/src/glog/logging.h.in
@@ -361,6 +361,9 @@ DECLARE_int32(minloglevel);
// default logging directory.
DECLARE_string(log_dir);
+// Set the log file mode.
+DECLARE_int32(logfile_mode);
+
// Sets the path of the directory into which to put additional links
// to the log files.
DECLARE_string(log_link);
diff --git a/src/logging.cc b/src/logging.cc
index 8936fe3..b7c2f4c 100644
--- a/src/logging.cc
+++ b/src/logging.cc
@@ -161,6 +161,8 @@ static const char* DefaultLogDir() {
return "";
}
+GLOG_DEFINE_int32(logfile_mode, 0664, "Log file mode/permissions.");
+
GLOG_DEFINE_string(log_dir, DefaultLogDir(),
"If specified, logfiles are written into this directory instead "
"of the default logging directory.");
@@ -899,7 +901,7 @@ bool LogFileObject::CreateLogfile(const string& time_pid_string) {
string string_filename = base_filename_+filename_extension_+
time_pid_string;
const char* filename = string_filename.c_str();
- int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0664);
+ int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, FLAGS_logfile_mode);
if (fd == -1) return false;
#ifdef HAVE_FCNTL
// Mark the file close-on-exec. We don't really care if this fails