CppLogging  1.0.4.0
C++ Logging Library
memory_appender.h
Go to the documentation of this file.
1 
9 #ifndef CPPLOGGING_APPENDERS_MEMORY_APPENDER_H
10 #define CPPLOGGING_APPENDERS_MEMORY_APPENDER_H
11 
12 #include "logging/appender.h"
13 
14 namespace CppLogging {
15 
17 
23 class MemoryAppender : public Appender
24 {
25 public:
27 
30  explicit MemoryAppender(size_t capacity = 0) : _buffer(capacity) {}
31  MemoryAppender(const MemoryAppender&) = delete;
33  virtual ~MemoryAppender() = default;
34 
37 
39  std::vector<uint8_t>& buffer() noexcept { return _buffer; }
41  const std::vector<uint8_t>& buffer() const noexcept { return _buffer; }
42 
43  // Implementation of Appender
44  void AppendRecord(Record& record) override;
45 
46 private:
47  std::vector<uint8_t> _buffer;
48 };
49 
50 } // namespace CppLogging
51 
52 #endif // CPPLOGGING_APPENDERS_MEMORY_APPENDER_H
Logging appender interface definition.
Logging appender interface.
Definition: appender.h:33
MemoryAppender & operator=(MemoryAppender &&)=delete
std::vector< uint8_t > & buffer() noexcept
Get memory buffer.
MemoryAppender(const MemoryAppender &)=delete
MemoryAppender & operator=(const MemoryAppender &)=delete
virtual ~MemoryAppender()=default
const std::vector< uint8_t > & buffer() const noexcept
Get constant memory buffer.
MemoryAppender(size_t capacity=0)
Initialize the appender with a given capacity.
void AppendRecord(Record &record) override
Append the given logging record.
MemoryAppender(MemoryAppender &&)=delete
Logging record.
Definition: record.h:37
C++ Logging project definitions.
Definition: appender.h:15