Main Page
Namespaces
Classes
Files
File List
File Members
libswarmio
include
swarmio
tool
LogBuffer.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <g3log/g3log.hpp>
4
#include <list>
5
#include <string>
6
#include <mutex>
7
8
namespace
swarmio::tool
9
{
10
class
LogBuffer
final
11
{
12
private
:
13
18
std::list<g3::LogMessage>
_messages
;
19
24
std::mutex
_mutex
;
25
26
public
:
27
33
void
ReceiveLogMessage
(g3::LogMessageMover logEntry)
34
{
35
std::unique_lock<std::mutex> guard(_mutex);
36
37
// Add to list
38
_messages.push_back(logEntry.get());
39
40
// Remove one if we are over the limit
41
if
(_messages.size() > 15)
42
{
43
_messages.pop_front();
44
}
45
}
46
52
std::list<g3::LogMessage>
GetMessages
()
53
{
54
std::unique_lock<std::mutex> guard(_mutex);
55
56
// Copy list
57
return
_messages
;
58
}
59
};
60
61
}
swarmio::tool
Definition:
Command.h:7
swarmio::tool::LogBuffer::_messages
std::list< g3::LogMessage > _messages
Internal list of messages.
Definition:
LogBuffer.h:18
swarmio::tool::LogBuffer
Definition:
LogBuffer.h:10
swarmio::tool::LogBuffer::GetMessages
std::list< g3::LogMessage > GetMessages()
Get a copy of the list of messages.
Definition:
LogBuffer.h:52
swarmio::tool::LogBuffer::_mutex
std::mutex _mutex
Mutex to protect the list of messages.
Definition:
LogBuffer.h:24
swarmio::tool::LogBuffer::ReceiveLogMessage
void ReceiveLogMessage(g3::LogMessageMover logEntry)
Receive log messages.
Definition:
LogBuffer.h:33
swarmros
Author(s):
autogenerated on Fri Apr 3 2020 03:42:48