vstream Class Reference
Logging and debugguing

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
vstream::Level | get_level () const
| operator std::ostream & ()
template<class T>
vstream & | operator<< (const T &text)
vstream & | operator<< (Level const l)
vstream & | operator<< (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 vstream & | instance ()
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

enum vstream::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 63 of file msgstream.hh.

## Member Function Documentation

## flush()

void vstream::flush | ( |  | ) |

inline

write pending output

Definition at line 280 of file msgstream.hh.

Referenced by set_stream().

## get_level()

vstream::Level vstream::get_level | ( |  | ) | const

inline

Returns
  the curent verbosity level

Definition at line 275 of file msgstream.hh.

Referenced by set_verbosity().

## instance()

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 144 of file msgstream.hh.

## operator<<() [1/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

  text | the text to be written to the stream

Returns
  a reference to this object

Definition at line 119 of file msgstream.hh.

## operator<<() [2/3]

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

a special handling to set the output level "inline"

Parameters

  l | the level of the following messages

## operator<<() [3/3]

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

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()

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

References flush(), show_debug(), and shows().

## set_verbosity()

void vstream::set_verbosity | ( | Level | l | ) |

set the verbosity output level

Parameters

  l |

References get_level().

## show_debug()

bool vstream::show_debug | ( |  | ) | const

inline

Returns
  true if the output level is equal or below "debug"

Definition at line 268 of file msgstream.hh.

References ml_debug, and shows().

Referenced by set_stream().

## shows()

bool vstream::shows | ( | Level | l | ) | const

inline

Parameters

  l | verbosity level

Returns
  true if cverb will show the given verbosity level

Definition at line 176 of file msgstream.hh.

Referenced by set_stream(), and show_debug().

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

- msgstream.hh