add option to reduce dump flush buffer size to 1
This commit is contained in:
@@ -82,7 +82,7 @@ void RotateFile::write(const unsigned char* value, const size_t size, const bool
|
||||
fwrite(value, (streamsize)size, 1, m_stream);
|
||||
m_fileSize += size;
|
||||
m_flushSize += size;
|
||||
if (m_flushSize > 16) {
|
||||
if (m_flushSize >= m_flushBuffer) {
|
||||
fflush(m_stream);
|
||||
m_flushSize = 0;
|
||||
}
|
||||
|
||||
@@ -43,10 +43,11 @@ class RotateFile {
|
||||
* @param fileName the name of the file write to.
|
||||
* @param maxSize the maximum size of the file to write to.
|
||||
* @param textMode whether to write each byte with prefixed timestamp and direction as text.
|
||||
* @param flushBuffer the size of the flush buffer.
|
||||
*/
|
||||
RotateFile(const string fileName, const unsigned int maxSize, const bool textMode = false)
|
||||
RotateFile(const string fileName, const unsigned int maxSize, const bool textMode = false, const unsigned int flushBuffer = 16)
|
||||
: m_enabled(false), m_fileName(fileName), m_maxSize(maxSize), m_textMode(textMode), m_stream(), m_fileSize(0),
|
||||
m_flushSize(0) {}
|
||||
m_flushSize(0), m_flushBuffer(flushBuffer) {}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
@@ -98,6 +99,9 @@ class RotateFile {
|
||||
|
||||
/** the number of bytes written to @a m_file since the last flush. */
|
||||
uint64_t m_flushSize;
|
||||
|
||||
/** the size of the flush buffer. */
|
||||
const unsigned int m_flushBuffer;
|
||||
};
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
Reference in New Issue
Block a user