Added truncating to IPC log buffer queue #4651
When the IPC log buffer is too large, the oldest log line is removed when a new log line is added.
This commit is contained in:
parent
aac59fbf7e
commit
e60b3a6feb
|
@ -116,7 +116,12 @@ void
|
|||
IpcLogOutputter::appendBuffer(const String& text)
|
||||
{
|
||||
ArchMutexLock lock(m_bufferMutex);
|
||||
m_buffer.push(text);
|
||||
if (m_buffer.size() >= m_bufferMaxSize) {
|
||||
// if the queue is exceeds size limit,
|
||||
// throw away the oldest item
|
||||
m_buffer.pop_front();
|
||||
}
|
||||
m_buffer.push_back(text);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -182,7 +187,7 @@ IpcLogOutputter::getChunk(size_t count)
|
|||
for (size_t i = 0; i < count; i++) {
|
||||
chunk.append(m_buffer.front());
|
||||
chunk.append("\n");
|
||||
m_buffer.pop();
|
||||
m_buffer.pop_front();
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "arch/IArchMultithread.h"
|
||||
#include "base/ILogOutputter.h"
|
||||
|
||||
#include <queue>
|
||||
#include <deque>
|
||||
|
||||
class IpcServer;
|
||||
class Event;
|
||||
|
@ -87,7 +87,7 @@ private:
|
|||
void appendBuffer(const String& text);
|
||||
|
||||
private:
|
||||
typedef std::queue<String> Buffer;
|
||||
typedef std::deque<String> Buffer;
|
||||
|
||||
IpcServer& m_ipcServer;
|
||||
Buffer m_buffer;
|
||||
|
|
Loading…
Reference in New Issue