Consolix
Loading...
Searching...
No Matches
consolix::MultiStream Class Reference

A class for handling multi-target log streams. More...

#include <MultiStream.hpp>

Public Member Functions

 MultiStream ()=default
 Default constructor for MultiStream without LogIt integration.
 
 ~MultiStream ()
 Destructor to flush the accumulated log content.
 
template<typename T>
MultiStreamoperator<< (const T &value)
 Overloaded operator<< for adding content to the stream.
 
MultiStreamoperator<< (std::ostream &(*manip)(std::ostream &))
 Overloaded operator<< for manipulators (e.g., std::endl).
 

Private Member Functions

void flush_to_console (const std::string &message) const
 Flush the accumulated message to the console on non-Windows platforms.
 

Private Attributes

std::ostringstream m_stream
 Internal stream for accumulating log content.
 

Detailed Description

A class for handling multi-target log streams.

MultiStream ensures consistent and platform-independent logging output:

  • On Windows, UTF-8 strings are automatically converted to CP866 to support legacy console encoding.
  • On Linux/macOS, UTF-8 strings are directly output to the console.
  • Supports ANSI color codes for enhanced readability.
  • Integrates with LogIt logging library for advanced log management (if enabled).
  • Supports LogIt integration (if enabled) and platform-specific console handling.

Definition at line 26 of file MultiStream.hpp.

Constructor & Destructor Documentation

◆ MultiStream()

consolix::MultiStream::MultiStream ( )
default

Default constructor for MultiStream without LogIt integration.

◆ ~MultiStream()

consolix::MultiStream::~MultiStream ( )
inline

Destructor to flush the accumulated log content.

Definition at line 57 of file MultiStream.hpp.

Member Function Documentation

◆ flush_to_console()

void consolix::MultiStream::flush_to_console ( const std::string & message) const
inlineprivate

Flush the accumulated message to the console on non-Windows platforms.

Parameters
messageThe message to flush.

Definition at line 110 of file MultiStream.hpp.

◆ operator<<() [1/2]

template<typename T>
MultiStream & consolix::MultiStream::operator<< ( const T & value)
inline

Overloaded operator<< for adding content to the stream.

Template Parameters
TThe type of the content to log.
Parameters
valueThe value to log.
Returns
Reference to the current MultiStream object.

Definition at line 85 of file MultiStream.hpp.

◆ operator<<() [2/2]

MultiStream & consolix::MultiStream::operator<< ( std::ostream &(* manip )(std::ostream &))
inline

Overloaded operator<< for manipulators (e.g., std::endl).

Parameters
manipManipulator function (e.g., std::endl).
Returns
Reference to the current MultiStream object.

Definition at line 93 of file MultiStream.hpp.

Member Data Documentation

◆ m_stream

std::ostringstream consolix::MultiStream::m_stream
private

Internal stream for accumulating log content.

Definition at line 99 of file MultiStream.hpp.


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