Collaboration diagram for Nesting Debug Output:
![]() |
int foobar(void) __attribute__ ((const)); int foobar(void) { Dout( dc::notice, "Entering foobar()" ); Dout( dc::notice, "Leaving foobar()" ); return 1; } int main(void) { Dout( dc::kernel, "The value of foobar() = " << foobar() << ", aint that nice?" ); return foobar(); }
This code would start a new debug message before the previous debug message is finished. Libcwd detects this and will output:
NOTICE: Entering foobar() NOTICE: Leaving foobar() KERNEL: The value of foobar() = 2, aint that nice?
Note the indentation and the fact that the printing of the label KERNEL was delayed.
foobar()
was a const function: it didn't matter whether or not it was called for the functionality of the application. But when it does matter, then one might want to do something like this:
Dout( dc::kernel|flush_cf|continued_cf, "Generating tables... " ); generate_tables(); Dout( dc::finish, "done" );
If generate_tables() would not print debug messages, then the output will look like:
KERNEL: Generating tables... done
When it does generated debug output, then the <unfinished> and <continued> labels are printed also:
KERNEL: Generating tables... <unfinished> NOTICE: Inside generate_tables() KERNEL: <continued> done
Finally, it is also possible to split a debug line into more than two parts by using the special dc::continued debug channel.
Dout( dc::notice|flush_cf|continued_cf, "Generating tables." ); for(int i = 0; i < 8; ++i) { generate_table(i); Dout( dc::continued, '.' ); } Dout( dc::finish, " done" );
When generate_table(i) doesn't print debug messages, then the output will look like:
NOTICE: Generating tables......... done
When it does generate debug output, then each dot would be surrounded by a <continued> .<unfinished> :
NOTICE: Generating tables.<unfinished> TABLE : Inside generate_table(0) NOTICE: <continued> .<unfinished>
etc.
Copyright © 2001 - 2004 Carlo Wood. All rights reserved.