OfLog() << "msg" with __TIMESTAMP__, __FILE__, etc.

Hi,

I’m trying to define a function which would use ofLog() cout-like syntax (don’t know how it’s called) which uses << to merge strings but at the same time it’d also want to automatically add __FILE__, __LINE__ defines to each call. Something like the following:

  
  
ofLog(OF_LOG_VERBOSE) << "[" << __TIMESTAMP__ << "][" << __FILE__ << " @ " << __LINE__ << "]" << msg << std::endl;  
  

… but wrapped into a single line function call with one param $msg appended like this:

  
  
ofLogWithFileAndTime() << msg;  
  

How could I define this as a macro or at least a function? I saw that ofLog implements the << operator but I don’t think that subclassing ofLog and overriding this method is a way to go. Wrapping the function call just seems as a more reasonable way out.

Best regards,
PB

hi! check out https://github.com/gameoverhack/ofxLogger and the extensive discussion in https://github.com/openframeworks/openFrameworks/issues/985, you should find what you need in there somewhere.

Thank you bilderbuchi