libcwdversion 2.0.0
The C++ Debugging Support Library
Loading...
Searching...
No Matches
Introduction (Debug Output)

Introduction to libcwd's ostream-based debug output.

Libcwd is an ostream oriented debug output facility. The class libcwd::DebugObject is associated with a single ostream.

Libcwd defines and internally uses only one object of that class, called a debug object, being libcwd::libcw_do.

Debug output is written using macros (Dout and DoutFatal), both of which are defined to use libcwd::libcw_do. More general macros exist (LibcwDout and LibcwDoutFatal) that allow you to use a different (custom) debug object.

Dout and DoutFatal take two arguments: the first argument is used to specify debug channels and control flags while the second argument should be a series of objects separated by << that you want to write to the ostream.

For example,

Dout(dc::notice|blank_label_cf|flush_cf, "Total count: " << count << "; Average: " << average);
#define Dout(cntrl,...)
Macro for writing debug output.
Definition debug.h:97

In this example dc::notice is one of the predefined debug channels. Debug channels are intended to control the amount of output of your application: you can switch the channels on and off.