From: Jesse Jones (jesjones_at_[hidden])
Date: 2001-11-24 15:16:24
At 11:45 AM +0100 11/24/01, Roland Weiss wrote:
>On Saturday 24 November 2001 04:38, you wrote:
>> Is anyone working on debugging or stream libraries
>> for Boost? By debugging libraries I mean things like:
>> - Note/Debug/Warning/Error message output, with
>> multiple channels so one can turn on debugging
>> for certain parts of the program, and specify
>> levels of message output.
>I've written a class template that takes as template
>value parameter the number of streams logging messages
>should go to.
Personally I don't like using iostreams for debug logging. I
experimented with this with CodeWarrior Pro 6 (I think it was) and
got insane amounts of bloat. Every file that used logging wound up
100K or more larger. Of course the linker will strip all this crap
out, but it make's it harder to get a first approximation of where
the bloat is and all that duplicate code has got to slow down both
compiling and linking.
>Each stream can be bound to a different
>ostream, and each stream has its own threshold (to
>prioritize logging messages).
I do this a bit differently. When clients want to log something they
can specify a logging category (eg LOG("Sockets", "Sent ", bytes, "
bytes to ", address, ".\n")). When LOG is called it assembles the
string (using overloaded ToStr functions) and passes the string and
the category to the logger. The logger checks to see if the category
is enabled and if it is hands the string off to zero or more log
sinks. Log sinks can write to a file, standout output, or where ever.
The nice thing about this is that it's simple to use, messages are
filtered with a meaningful name instead of a number, there's no bloat
yet it's still type safe and extensible, and it can be easily
customized with different sinks.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk