UCILoader 1.1.2
Small C++ library that allows user to connect to a chess engines via UCI protocol.
Loading...
Searching...
No Matches
UCILoader::LogBuffer Class Reference

Thread-safe buffer for storing log messages. More...

#include <Logger.h>

Public Member Functions

void push_back (const std::string &msg)
 Add a message to the buffer.
 
std::vector< std::string > snapshot () const
 Get a snapshot of all messages currently in the buffer.
 

Detailed Description

Thread-safe buffer for storing log messages.

LogBuffer provides thread-safe storage of log messages in memory. It's useful for capturing recent messages for debugging or diagnostics without writing to disk.

The buffer maintains a snapshot of logged messages that can be retrieved with the snapshot() method.

Usage Example:

// Create a buffer for storing logs
// Create a logger that stores messages in the buffer
auto logger = Loggers::toBuffer(buffer).build();
// ... perform operations that log messages ...
// Get a snapshot of logged messages
auto messages = buffer.snapshot();
for (const auto& msg : messages) {
std::cout << msg << std::endl;
}
Thread-safe buffer for storing log messages.
Definition: Logger.h:449
std::vector< std::string > snapshot() const
Get a snapshot of all messages currently in the buffer.
Definition: Logger.cpp:236
std::unique_ptr< Logger > build()
Build and return the final logger instance.
Definition: Logger.cpp:227
LoggerBuilder toBuffer(LogBuffer &buffer)
Create a logger that stores messages in abuffer.
Definition: Logger.cpp:195

Member Function Documentation

◆ push_back()

void UCILoader::LogBuffer::push_back ( const std::string &  msg)

Add a message to the buffer.

Parameters
msgThe message string to add

◆ snapshot()

std::vector< std::string > UCILoader::LogBuffer::snapshot ( ) const

Get a snapshot of all messages currently in the buffer.

Returns
A vector of log message strings

The documentation for this class was generated from the following files: