diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-11-16 23:12:16 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-11-16 23:12:16 +0000 |
commit | 521c70553125b6da53c65a60e36fcc18aec36565 (patch) | |
tree | dc41c006f1c4ac7f40f98be7f1ef318c13e5d15f /lib/common/Logging.h | |
parent | 258e57eaecfe85356181706d70141a2563d22737 (diff) |
Add option to truncate log file at start of every backup.
Prevents backup log files from becoming too large.
Diffstat (limited to 'lib/common/Logging.h')
-rw-r--r-- | lib/common/Logging.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/common/Logging.h b/lib/common/Logging.h index ff557430..ce78413e 100644 --- a/lib/common/Logging.h +++ b/lib/common/Logging.h @@ -467,13 +467,15 @@ class Logging Log::INFO #endif ) - : mCurrentLevel(InitialLevel) + : mCurrentLevel(InitialLevel), + mTruncateLogFile(false) { } static std::string GetOptionString(); int ProcessOption(signed int option); static std::string GetUsageString(); int mCurrentLevel; // need an int to do math with + bool mTruncateLogFile; Log::Level GetCurrentLevel() { return (Log::Level) mCurrentLevel; @@ -489,9 +491,9 @@ class FileLogger : public Logger : mLogFile("") { /* do not call */ } public: - FileLogger(const std::string& rFileName, Log::Level Level) + FileLogger(const std::string& rFileName, Log::Level Level, bool append) : Logger(Level), - mLogFile(rFileName, O_WRONLY | O_CREAT | O_APPEND) + mLogFile(rFileName, O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC)) { } virtual bool Log(Log::Level Level, const std::string& rFile, |