LogIt++
Loading...
Searching...
No Matches
logit::LogStream Class Reference

A stream-based logger that collects log messages using the << operator. More...

#include <LogStream.hpp>

Public Member Functions

 LogStream (const LogLevel &level, const std::string &file, const int &line, const std::string &function, const int &logger_index)
 Constructor.
 
 ~LogStream ()
 Destructor that logs the collected message when the object goes out of scope.
 
template<typename T >
LogStreamoperator<< (const T &value)
 Overloaded << operator to accumulate log content.
 

Private Attributes

LogLevel m_level
 Log level.
 
std::ostringstream m_stream
 Stream for accumulating log content.
 
std::string m_file
 Source file name.
 
int m_line
 Line number.
 
std::string m_function
 Function name.
 
int m_logger_index
 Logger index.
 

Detailed Description

A stream-based logger that collects log messages using the << operator.

The LogStream class allows for logging messages in a stream-like manner. It collects log data through the << operator and automatically sends the log message when the object is destroyed.

Definition at line 18 of file LogStream.hpp.

Constructor & Destructor Documentation

◆ LogStream()

logit::LogStream::LogStream ( const LogLevel & level,
const std::string & file,
const int & line,
const std::string & function,
const int & logger_index )
inline

Constructor.

Parameters
levelThe log level.
fileSource file name.
lineLine number in the source file.
functionFunction name.
logger_indexLogger index to use.

Definition at line 27 of file LogStream.hpp.

◆ ~LogStream()

logit::LogStream::~LogStream ( )
inline

Destructor that logs the collected message when the object goes out of scope.

When the LogStream object is destroyed, the log message is automatically sent using the Logger instance. The message is collected through the << operator and stored in an internal string stream until the object is destructed.

Definition at line 42 of file LogStream.hpp.

Member Function Documentation

◆ operator<<()

template<typename T >
LogStream & logit::LogStream::operator<< ( const T & value)
inline

Overloaded << operator to accumulate log content.

Template Parameters
TThe type of value to log.
Parameters
valueThe value to add to the log message.
Returns
A reference to the LogStream for chaining.

Definition at line 58 of file LogStream.hpp.

Member Data Documentation

◆ m_file

std::string logit::LogStream::m_file
private

Source file name.

Definition at line 66 of file LogStream.hpp.

◆ m_function

std::string logit::LogStream::m_function
private

Function name.

Definition at line 68 of file LogStream.hpp.

◆ m_level

LogLevel logit::LogStream::m_level
private

Log level.

Definition at line 64 of file LogStream.hpp.

◆ m_line

int logit::LogStream::m_line
private

Line number.

Definition at line 67 of file LogStream.hpp.

◆ m_logger_index

int logit::LogStream::m_logger_index
private

Logger index.

Definition at line 69 of file LogStream.hpp.

◆ m_stream

std::ostringstream logit::LogStream::m_stream
private

Stream for accumulating log content.

Definition at line 65 of file LogStream.hpp.


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