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 (bool use_utf8=true)
 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.
 
bool use_utf8
 Flag indicating whether UTF-8 encoding should be used.
 

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 ( bool use_utf8 = true)
inline

Default constructor for MultiStream without LogIt integration.

Parameters
use_utf8Flag to indicate if UTF-8 encoding should be used.

Definition at line 53 of file MultiStream.hpp.

◆ ~MultiStream()

consolix::MultiStream::~MultiStream ( )
inline

Destructor to flush the accumulated log content.

Definition at line 58 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 113 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 86 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 94 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 100 of file MultiStream.hpp.

◆ use_utf8

bool consolix::MultiStream::use_utf8
private

Flag indicating whether UTF-8 encoding should be used.

Definition at line 108 of file MultiStream.hpp.


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