From d6e6182e65e19bb60f41480438701dc5c885ee05 Mon Sep 17 00:00:00 2001 From: Victor Luchits Date: Fri, 10 May 2019 12:34:37 +0300 Subject: [PATCH] Close the target file in CLogFileTarget's destructor --- lib/logging/CLogger.cpp | 4 ++++ lib/logging/CLogger.h | 1 + 2 files changed, 5 insertions(+) diff --git a/lib/logging/CLogger.cpp b/lib/logging/CLogger.cpp index d354f74ac..72bb3006a 100644 --- a/lib/logging/CLogger.cpp +++ b/lib/logging/CLogger.cpp @@ -402,3 +402,7 @@ void CLogFileTarget::write(const LogRecord & record) const CLogFormatter & CLogFileTarget::getFormatter() const { return formatter; } void CLogFileTarget::setFormatter(const CLogFormatter & formatter) { this->formatter = formatter; } + +CLogFileTarget::~CLogFileTarget() { + file.close(); +} diff --git a/lib/logging/CLogger.h b/lib/logging/CLogger.h index 5273486d3..d2a15fb39 100644 --- a/lib/logging/CLogger.h +++ b/lib/logging/CLogger.h @@ -213,6 +213,7 @@ public: /// Constructs a CLogFileTarget and opens the file designated by filePath. If the append parameter is true, the file /// will be appended to. Otherwise the file designated by filePath will be truncated before being opened. explicit CLogFileTarget(boost::filesystem::path filePath, bool append = true); + ~CLogFileTarget(); const CLogFormatter & getFormatter() const; void setFormatter(const CLogFormatter & formatter);