From 9cca047ec7fb78eb9b190d2a822282e5f10f5cf7 Mon Sep 17 00:00:00 2001 From: randomdan Date: Sat, 30 Nov 2013 16:06:06 +0000 Subject: Allow specification of log file access mode --- project2/files/fileLog.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/project2/files/fileLog.cpp b/project2/files/fileLog.cpp index 1f7e6e9..078e00b 100644 --- a/project2/files/fileLog.cpp +++ b/project2/files/fileLog.cpp @@ -5,7 +5,7 @@ class FileLogDriver : public LogDriverBase { public: FileLogDriver() : - file(fopen(path.c_str(), "a")) + file(fopen(path.c_str(), openmode.c_str())) { } ~FileLogDriver() @@ -30,6 +30,7 @@ class FileLogDriver : public LogDriverBase { static int level; private: static std::string path; + static std::string openmode; FILE * file; }; @@ -38,10 +39,13 @@ DECLARE_OPTIONS(FileLogDriver, "File log options") "Log to file with level (default OFF)") ("common.filelog.path", Options::value(&path, "/var/log/project2.log"), "Log to file with path (default '/var/log/project2.log')") +("common.filelog.openmode", Options::value(&openmode, "a"), + "How to open the log file (see man 3 fopen) (default 'a')") END_OPTIONS(FileLogDriver); int FileLogDriver::level; std::string FileLogDriver::path; +std::string FileLogDriver::openmode; DECLARE_LOGGER_LOADER("file", FileLogDriver); -- cgit v1.2.3