2023-02-08 11:04:11 +00:00
|
|
|
//
|
|
|
|
// CompressedLogFile.h
|
|
|
|
//
|
|
|
|
// Library: Foundation
|
|
|
|
// Package: Logging
|
|
|
|
// Module: CompressedLogFile
|
|
|
|
//
|
|
|
|
// Definition of the LogFile class.
|
|
|
|
//
|
|
|
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
|
|
|
// and Contributors.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef Foundation_CompressedLogFile_INCLUDED
|
|
|
|
#define Foundation_CompressedLogFile_INCLUDED
|
|
|
|
|
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
#include "Poco/Buffer.h"
|
2023-02-08 11:04:11 +00:00
|
|
|
#include "Poco/Foundation.h"
|
|
|
|
#include "Poco/LogFile.h"
|
|
|
|
|
|
|
|
#include <lz4.h>
|
|
|
|
#include <lz4frame.h>
|
|
|
|
|
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
namespace Poco
|
|
|
|
{
|
2023-02-08 11:04:11 +00:00
|
|
|
|
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
class Foundation_API CompressedLogFile : public LogFile
|
2023-02-08 11:04:11 +00:00
|
|
|
{
|
|
|
|
public:
|
2023-02-13 09:22:33 +00:00
|
|
|
CompressedLogFile(const std::string & path);
|
|
|
|
/// Allocates buffer and initializes compession state.
|
2023-02-08 11:04:11 +00:00
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
~CompressedLogFile();
|
|
|
|
/// Destoys CompressedLogFile
|
2023-02-08 11:04:11 +00:00
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
void write(const std::string & text, bool flush = true);
|
|
|
|
/// Writes the given text to the compressed log file.
|
|
|
|
/// If flush is true, the text will be immediately
|
|
|
|
/// flushed to the file.
|
2023-02-08 11:04:11 +00:00
|
|
|
|
|
|
|
private:
|
2023-02-13 09:22:33 +00:00
|
|
|
Poco::Buffer<char> _buffer;
|
2023-02-08 11:04:11 +00:00
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
LZ4F_preferences_t _kPrefs;
|
|
|
|
LZ4F_compressionContext_t _ctx;
|
2023-02-08 11:04:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Poco
|
|
|
|
|
|
|
|
|
|
|
|
#endif // Foundation_CompressedLogFile_INCLUDED
|