|
Boost : |
From: Darren Cook (darren_at_[hidden])
Date: 2005-02-15 20:30:35
>> Hhmm, no, I've lost the ability to write:
>> LOG("a="<<a<<",b="<<b);
>
> ... The reason is that the basic_entry requires the creation
> and usage of an ostringstream which is a fairly heavyweight object. It
> all depends really on what you want x to be. If x were always going to
> be a string literal for example, you could have instead:
x is hardly ever a string literal, so I can accept the ostringstream overhead.
Taking a step back, many of my log lines are exactly like the above example,
so a very useful macro would work like John Torjo's smart assert and I could
write:
LOGVARS(a)(b);
As my macro will insert file/line/function name I generally don't need to
write anything else.
> (unless of course you have a global log called alm, as it seems you would
> need to have by your macro, in which case you could omit the first
> parameter).
This is how I currently do it: global logs with different macros to write to
each. But my current logging is too inflexible, so, yes, I should switch to
a single macro with logname as the first parameter.
Darren
P.S. Even better would be able to write LOGVARS(*) and have it log all
function parameters and local vars that are currently in scope. Is this
something that the Wave library could do, or does it require a full C++ parser?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk