vstream Class Reference

A output stream to enable certain levels of verbosity. More...

#include <mia/core/msgstream.hh>

Public Types

enum  Level {
  ml_trace, ml_debug, ml_info, ml_message,
  ml_warning, ml_fail, ml_error, ml_fatal,
  ml_undefined
}
 

Public Member Functions

void flush ()
 write pending output More...
 
vstream::Level get_level () const
 
 operator std::ostream & ()
 
vstreamoperator<< (Level const l)
 
template<class T >
vstreamoperator<< (const T &text)
 
vstreamoperator<< (std::ostream &(*f)(std::ostream &))
 
std::ostream & set_stream (std::ostream &os)
 
void set_verbosity (Level l)
 
bool show_debug () const
 
bool shows (Level l) const
 

Static Public Member Functions

static vstreaminstance ()
 
static void set_output_target (std::ostream *os)
 

Detailed Description

A output stream to enable certain levels of verbosity.

This class impelemtns a std::ostream like class to output messages during run-time, supporting various levels of verbosity. The class is implemened as a singleton. On initialization it is set to use std::cerr as output stream, but this can be replaced by any type implementing the std::ostream interface.

Remarks
if -DNDEBUG is set, the levels debug and trace are not compiled in - i.e. the corresponding output operators are replaced by dummy functions that should be optimized away.

Definition at line 55 of file msgstream.hh.

Member Enumeration Documentation

◆ Level

Output verbosity level threshhold, ml_trace is the lowest threshhold and ml_fatal the highest. Output is written, when the output threshold is above or equal to the one set within the output stream.

Enumerator
ml_trace 

write trace of function calls and higher, disabled with -DNDEBUG

ml_debug 

write debugging information and higher, disabled with -DNDEBUG

ml_info 

write additional info about the data processed and higher

ml_message 

write process status messages and higher

ml_warning 

write warnings and higher

ml_fail 

write failture messages (for tests) and higher

ml_error 

write non-fatal error messages and higher

ml_fatal 

write only fatal error messages

ml_undefined 

stopper

Definition at line 62 of file msgstream.hh.

Member Function Documentation

◆ flush()

void vstream::flush ( )
inline

write pending output

Definition at line 270 of file msgstream.hh.

◆ get_level()

vstream::Level vstream::get_level ( ) const
inline
Returns
the curent verbosity level

Definition at line 265 of file msgstream.hh.

◆ instance()

static vstream& vstream::instance ( )
static

initialise a stream that writes only messages above a certain verbosity level

Referenced by CTrace::CTrace(), cvdebug(), cverr(), cvfail(), cvfatal(), cvinfo(), cvmsg(), cvwarn(), and CTrace::~CTrace().

◆ operator std::ostream &()

vstream::operator std::ostream & ( )
inline

Transparent conversion operator to an std::ostream.

Definition at line 141 of file msgstream.hh.

References EXPORT_CORE, g_verbose_dict, output, and set_verbose().

◆ operator<<() [1/3]

vstream& vstream::operator<< ( Level const  l)

a special handling to set the output level "inline"

Parameters
lthe level of the following messages

◆ operator<<() [2/3]

template<class T >
vstream& vstream::operator<< ( const T &  text)
inline

general output routine; output is only given, if the data verbosity level is set higher or equal to the stream verbosity level. x1

Parameters
textthe text to be written to the stream
Returns
a reference to this object

Definition at line 118 of file msgstream.hh.

References operator<<().

◆ operator<<() [3/3]

vstream& vstream::operator<< ( std::ostream &(*)(std::ostream &)  f)

A funny construct to enable std::endl to work on this stream idea of Dave Brondsema: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8567

◆ set_output_target()

static void vstream::set_output_target ( std::ostream *  os)
static

Set the output target with which the stream should be initialized if std::cerr is not to be used.

◆ set_stream()

std::ostream& vstream::set_stream ( std::ostream &  os)

sets the output stream

Parameters
os
Returns
the old output stream

◆ set_verbosity()

void vstream::set_verbosity ( Level  l)

set the verbosity output level

Parameters
l

◆ show_debug()

bool vstream::show_debug ( ) const
inline
Returns
true if the output level is equal or below "debug"

Definition at line 258 of file msgstream.hh.

◆ shows()

bool vstream::shows ( Level  l) const
inline
Parameters
lverbosity level
Returns
true if cverb will show the given verbosity level

Definition at line 172 of file msgstream.hh.


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