Main Page   Reference Manual   Namespace List   Compound List   Namespace Members   Compound Members   File Members  

Writing Debug Output: Introduction
Collaboration diagram for Writing Debug Output: Introduction:

Introduction

Libcwd is an ostream oriented debug output facility.  The class libcwd::debug_ct represents 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 seperated 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, data)
Macro for writing debug output.
Definition: debug.h:154
control_flag_t const blank_label_cf
Replace label by white space.
Definition: control_flag.h:47
control_flag_t const flush_cf
Flush ostream after writing this output.
Definition: control_flag.h:56
channel_ct notice
Definition: debug.cc:460

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.

Copyright © 2001 - 2004 Carlo Wood.  All rights reserved.