libcwdversion 2.0.0
The C++ Debugging Support Library
Loading...
Searching...
No Matches
debug.h File Reference

This is the main header file of libcwd. More...

#include "cwds_debug.h"
#include "libraries_debug.h"
#include <libcwd/init_functions.h>

Go to the source code of this file.

Classes

struct  libcwd::Indent
 Interface for marking scopes with indented debug output. More...
struct  libcwd::Mark
 Interface for marking scopes with a marker character. More...
class  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...

Namespaces

namespace  libcwd
 namespace for libcwd.

Macros

#define Debug(...)
 Encapsulation macro for general debugging code.
#define Dout(cntrl, ...)
 Macro for writing debug output.
#define DoutEntering(cntrl, ...)
#define DoutFatal(cntrl, ...)
 Macro for writing fatal debug output to the default debug object libcw_do .
#define ForAllDebugChannels(...)
 Looping over all debug channels.
#define ForAllDebugObjects(...)
 Looping over all debug objects.
#define CW_DEBUG   1
 Define this macro as 1 when either CWDEBUG is defined or NDEBUG is not defined, otherwise as 0.

Detailed Description

Don't include this header file directly. Instead use a custom debug.h header file that includes this file, that will allow others to compile your application without having libcwd installed.

Macro Definition Documentation

◆ Debug

#define Debug ( ...)
Value:
#define LIBCWD_DEBUG_CHANNELS
The namespace containing the current debug channels (dc) namespace.
Definition cwds_debug.h:57
#define LibcwDebug(dc_namespace,...)
General debug macro.
Definition macro_Libcwd_macros.h:31

The parameter of this macro can be arbitrary code that will be eliminated from the application when the macro CWDEBUG is not defined.

It uses the namespaces LIBCWD_DEBUG_CHANNELS and libcwd, making it unnecessary to use the the full scopes for debug channels and utility functions provided by libcwd.

Examples:

Debug(main_reached()); // Must be called at the top of main. Does configuration consistency check.
// Note that normally you should call instead:
Debug(NAMESPACE_DEBUG::init()); // This already calls main_reached(), as well as read_rcfile(), etc.
Debug(dc::notice.on()); // Switch debug channel NOTICE on.
Debug(libcw_do.off()); // Turn all debugging temporarily off.
Debug(list_channels_on(libcw_do)); // List all debug channels (already done by init()).
Debug(libcw_do.set_ostream(&std::cout, &mutex)); // use โ€›mutex' as lock for std::cout.
Debug(libcw_do.set_ostream(&std::cout)); // Use std::cout as debug output stream, leaving the previously configured mutex.
Debug(libcw_do.inc_indent(4)); // Increment indentation by 4 spaces. Or use the RAI object libcwd::Indent.
Debug(libcw_do.get_ostream()->flush()); // Flush the current debug output stream.
void off()
Turn this debug object off.
Definition DebugObject.inl.h:237
#define Debug(...)
Encapsulation macro for general debugging code.
Definition debug.h:69
void inc_indent(unsigned short indentation)
Increment number of spaces to indent.
Definition DebugObject.inl.h:84
void set_ostream(std::ostream *os)
Set output device (single threaded applications).
Definition debug.cxx:1601
std::ostream * get_ostream() const
Get the ostream device as set with set_ostream().
Definition DebugObject.inl.h:117

◆ Dout

#define Dout ( cntrl,
... )
Value:
#define LibcwDout(dc_namespace, debug_obj, cntrl,...)
General debug output macro.
Definition macro_Libcwd_macros.h:78
DebugObject libcw_do
The default debug object.
Definition debug.cxx:222

This macro is used for writing debug output to the default debug object libcw_do . No code is generated when the macro CWDEBUG is not defined, in that case the macro Dout is replaced by white space.

The macro Dout uses libcwds debug object libcw_do . You will have to define your own macro when you want to use a second debug object.

See also
Control Flags
Predefined Debug Channels
Defining your own debug channels
Defining your own debug objects
Nested debug calls

Examples:

Dout(dc::notice, "Hello World");
Dout(dc::warning, "Out of memory in function " << func_name);
Dout(dc::notice|blank_label_cf, "The content of the object is: " << std::hex << obj);
#define Dout(cntrl,...)
Macro for writing debug output.
Definition debug.h:97

◆ DoutEntering

#define DoutEntering ( cntrl,
... )
Value:
int __cwds_debug_indentation = 2; \
LibcwDoutScopeBegin(LIBCWD_DEBUG_CHANNELS, ::libcwd::libcw_do, cntrl) \
LibcwDoutStream << "Entering " << __VA_ARGS__; \
LibcwDoutScopeEnd; \
::libcwd::Indent __cwds_debug_indent(__cwds_debug_indentation);
Interface for marking scopes with indented debug output.
Definition debug.h:173

Debugging macro.

Print "Entering " << data to channel cntrl and increment debugging output indentation until the end of the current scope.