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

Controlling which debug output is emitted by toggling channels on and off. More...

Topics

 Predefined Debug Channels
 Generated API reference for the debug channels supplied by libcwd.

Classes

class  libcwd::Channel
 This object represents a debug channel, it has a fixed label. A debug channel can be viewed upon as a single bit: on or off. More...

Detailed Description

Whenever debug output is written, one or more debug channels must be specified. The debug output is then written to the ostream of the debug object unless the debug object is turned off or when all specified debug channels are off. Each debug channel can be turned on and off independently.

Libcwd has defined six debug channels in namespace libcwd::channels::dc (See Predefined Debug Channels). New debug channels can be defined by the user in namespace LIBCWD_DEBUG_CHANNELS::dc, which is as simple as creating a new Channel object.

Example,

NAMESPACE_DEBUG_CHANNELS_START
Channel mychan("MYLABEL");
NAMESPACE_DEBUG_CHANNELS_END
This object represents a debug channel, it has a fixed label. A debug channel can be viewed upon as a...
Definition Channel.h:74

Multiple debug channels can be given by using operator| between the channel names. This shouldn't be read as `or' but merely be seen as the bit-wise OR operation on the bit-masks that these channels actually represent.

See also
control-flags

Example:

Dout(dc::notice, "Libcwd is a great library");
#define Dout(cntrl,...)
Macro for writing debug output.
Definition debug.h:97

gives as result

NOTICE: Libcwd is a great library

and

#ifdef CWDEBUG
NAMESPACE_DEBUG_CHANNELS_START
libcwd::Channel hello("HELLO");
NAMESPACE_DEBUG_CHANNELS_END
Dout(dc::hello, "Hello World!");
Dout(dc::kernel|dc::io, "This is written when either the dc::kernel "
"or dc::io channel is turned on.");
This object represents a debug channel, it has a fixed label. A debug channel can be viewed upon as a...
Definition Channel.h:74

gives as result

HELLO : Hello World!
KERNEL: This is written when either the kernel or io channel is turned on.