Logging with timestamp

I’ve been using the ofLog class for easy logging in my of apps for some time now. And in order to debug and profile better I would like to have a timestamp in each log message too, rather than just the level.

I’ve searched around and came across this addon, which does everything I want and more https://github.com/gameoverhack/ofxLogger. I would like though to keep my app to as little external dependencies as possible, for ease of maintainability and installation.

Therefore, I was wondering if any more oF savy user wouldn’t be able to tell me how to achieve a timestamp in there without necessarily including a new addon. I mean, isn’t there some way in oF to configure the logging? As far as I know this seems to be pretty standard feature of any logging capabilities.

Thanks in advance!

Hi, there’s ofGetTimestampString() you can just append it to the message you are logging.
There seem to be no configuration in ofLog for adding the timestamp automatically.
Anyways you could achive that easily with a macro or your own custom function.


Thanks for your reply roy. I just took that two ideas you gave of the macro and the ofGetTimestampString() and simply did this:

#define ofLogNotice() ofLogNotice() << ofGetTimestampString("[%Y-%m-%d %H:%M:%S.%i] ")

It’s crazy simply and will not serve for most people. But, it was just what I was looking for. A quick hack that does help better debugging/profiling in some of my apps.