
On 4/29/05, Gennadiy Rozental <gennadiy.rozental@thomson.com> wrote:
"Darren Cook" <darren@dcook.org> wrote in message news:4272B304.3000100@dcook.org...
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).
Yep. My fault.
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;
No. It's not really convinient isn't it?
I understand that f log statements will interfere with original log statement. The trick is to make sure that all prefixes are printed correctly:
a.cpp:14: Print result of f(): b.cpp:75: Enter f() b.cpp:95: Exit f() a.cpp:14: 1234
The proposed implementation yields this (modulo any prefixes): Enter f() Exit f() Print result of f(): 1234 Because each message is built up in a temporary stream and then fired off to the logger in its entirety. Gennadiy: to do what you suggest would seem to me to require (a) no buffering and (b) an interface which is likely not thread-safe. Or am I missing something. -- Caleb Epstein caleb dot epstein at gmail dot com