StreamLog 1.0.0
A lightweight C++11 logging library with stream-based API
Loading...
Searching...
No Matches
StreamLog::LogStatement Class Reference

RAII wrapper for building and committing log messages. More...

#include <streamlog.hpp>

Public Member Functions

 LogStatement (LogStatement &&other) noexcept
 Move constructor.
 LogStatement (StreamLog &logger)
 Construct LogStatement bound to a logger.
template<typename T>
LogStatementoperator<< (const T &value)
 Stream insertion operator for generic types.
LogStatementoperator<< (const char *value)
 Stream insertion operator for C-strings.
void clearBuffer ()
 Clear the internal message buffer.
std::string getBufferContent () const
 Get current buffer contents.
void appendToBuffer (const std::string &content)
 Append content to buffer.
 ~LogStatement ()
 Destructor commits the log message.

Detailed Description

RAII wrapper for building and committing log messages.

LogStatement accumulates message fragments via operator<< and commits the complete message when destroyed. Supports streaming of built-in types, strings, and optionally STL containers.

Constructor & Destructor Documentation

◆ LogStatement() [1/2]

StreamLog::LogStatement::LogStatement ( LogStatement && other)
noexcept

Move constructor.

Parameters
otherSource LogStatement to move from

◆ LogStatement() [2/2]

StreamLog::LogStatement::LogStatement ( StreamLog & logger)

Construct LogStatement bound to a logger.

Parameters
loggerReference to parent StreamLog instance

◆ ~LogStatement()

StreamLog::LogStatement::~LogStatement ( )

Destructor commits the log message.

RAII pattern: message is written to file/console when LogStatement goes out of scope.

Member Function Documentation

◆ appendToBuffer()

void StreamLog::LogStatement::appendToBuffer ( const std::string & content)

Append content to buffer.

Parameters
contentString to append

◆ clearBuffer()

void StreamLog::LogStatement::clearBuffer ( )

Clear the internal message buffer.

◆ getBufferContent()

std::string StreamLog::LogStatement::getBufferContent ( ) const

Get current buffer contents.

Returns
String representation of accumulated message

◆ operator<<() [1/2]

LogStatement & StreamLog::LogStatement::operator<< ( const char * value)
inline

Stream insertion operator for C-strings.

Parameters
valueC-string to append
Returns
Reference to this LogStatement for chaining

◆ operator<<() [2/2]

template<typename T>
LogStatement & StreamLog::LogStatement::operator<< ( const T & value)
inline

Stream insertion operator for generic types.

Template Parameters
TType supporting operator<< to std::ostream
Parameters
valueValue to append to log message
Returns
Reference to this LogStatement for chaining

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