浏览代码

Close the target file in CLogFileTarget's destructor

Victor Luchits 6 年之前
父节点
当前提交
d6e6182e65
共有 2 个文件被更改,包括 5 次插入0 次删除
  1. 4 0
      lib/logging/CLogger.cpp
  2. 1 0
      lib/logging/CLogger.h

+ 4 - 0
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();
+}

+ 1 - 0
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);