summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2013-11-30 16:06:06 +0000
committerrandomdan <randomdan@localhost>2013-11-30 16:06:06 +0000
commit0c3d9b50b57c2bde69141980fa00ddf4a32d71aa (patch)
treed6722759727bb6e6ed54e13b5ad5418b1894a5fe
parentRefactor to set up columns in a const way by calling execute() early, before ... (diff)
downloadproject2-0c3d9b50b57c2bde69141980fa00ddf4a32d71aa.tar.bz2
project2-0c3d9b50b57c2bde69141980fa00ddf4a32d71aa.tar.xz
project2-0c3d9b50b57c2bde69141980fa00ddf4a32d71aa.zip
Allow specification of log file access mode
-rw-r--r--project2/files/fileLog.cpp6
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);