diff options
-rw-r--r-- | project2/files/fileLog.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
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 <arg> (default OFF)") ("common.filelog.path", Options::value(&path, "/var/log/project2.log"), "Log to file with path <arg> (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); |