
29 Apr
2005
29 Apr
'05
10:19 p.m.
Another thing (from the same domain) that I found especially difficult to deal with in my logging implementation is "intermixed logging":
BOOST_LOG(..) << "Print result of f(): " << f();
... void f() { BOOST_LOG(..) << "Enter f()"; ... BOOST_LOG(..) << "Exit f()"; }
Now to make it properly formatter isn't trivial at all.
(For the example to make sense f() shouldn't be void; I've assumed it is int). Can a logging library really help here? Don't you have to write: int f_ret=f();BOOST_LOG(..) << "Print result of f(): "<<f_ret; For when you want logging to compile out completely then a LOG_PREPARE() macro may be useful: BOOST_LOG_PREPARE(int f_ret=f()); BOOST_LOG(.., "Print result of f(): "<<f_ret); Darren