
18 Mar
2004
18 Mar
'04
11:41 p.m.
I think it's the wrong approach. In our company we have implemented logging through macros which has one very important property: When I write
LOG_DEBUG( whatever() );
I have a macro like this: std::ostream *logfile=&std::cout; //Go to screen if not set #define LOG(expr) \ *logfile<<"\n"<<BOOST_CURRENT_FUNCTION<<":"<<__LINE__<<":\n"<<expr // To disable logging: //#define LOG(expr) (void(0)) I can then use like this: LOG("e="<<e<<", data:"<<*p); The problem comes when I have a function that takes an ostream; then I have to expose the internals: LOG("Here is data:");LOG(obj->debug_info(*logfile,true,false)); Is there a better way? Darren