mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 18:42:41 +01:00
fix(logs): synchronise log file rotation and compression.
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
#include "Poco/File.h"
|
||||
#include "Poco/DateTimeFormatter.h"
|
||||
#include "Poco/NumberFormatter.h"
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/Condition.h"
|
||||
#include <atomic>
|
||||
|
||||
|
||||
@@ -51,6 +53,8 @@ public:
|
||||
/// and creates and returns a new log file.
|
||||
/// The given LogFile object is deleted.
|
||||
|
||||
void close();
|
||||
|
||||
void compress(bool flag = true);
|
||||
/// Enables or disables compression of archived files.
|
||||
|
||||
@@ -58,10 +62,21 @@ protected:
|
||||
void moveFile(const std::string& oldName, const std::string& newName);
|
||||
bool exists(const std::string& name);
|
||||
|
||||
Poco::FastMutex _rotateMutex;
|
||||
|
||||
// Log rotation must wait until all of the compression tasks complete
|
||||
int _compressingCount;
|
||||
Poco::Condition _compressingComplete;
|
||||
|
||||
private:
|
||||
|
||||
friend class ArchiveCompressor;
|
||||
|
||||
ArchiveStrategy(const ArchiveStrategy&);
|
||||
ArchiveStrategy& operator = (const ArchiveStrategy&);
|
||||
|
||||
void compressFile(const std::string& path);
|
||||
|
||||
std::atomic<bool> _compress;
|
||||
std::atomic<ArchiveCompressor*> _pCompressor;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user