So I’m very new to OpenFrameworks I have a little background in Processing and I’m wondering how the ofLog() funciton works. I just want to be able to print some values out to the console and it seems like ofLog would do it but I dont understand the parameters its taking and what they are doing for me. Also its not printing anything to the console when i run it. if someone can explain that to me, it would be awesome!
Hi. If you look at the file ofLog.h, you’ll see
enum ofLogLevel{
OF_LOG_VERBOSE,
OF_LOG_NOTICE,
OF_LOG_WARNING,
OF_LOG_ERROR,
OF_LOG_FATAL_ERROR,
OF_LOG_SILENT //this one is special and should always be last - set ofSetLogLevel to OF_SILENT to not recieve any messages
};
//--------------------------------------------------
void ofSetLogLevel(ofLogLevel logLevel);
void ofLog(ofLogLevel logLevel, string message);
void ofLog(ofLogLevel logLevel, const char* format, ...);
With ofSetLogLevel you can set which log events should be displayed (so OF_LOG_VERBOSE, OF_LOG_NOTICE, OF_LOG_WARNING, OF_LOG_ERROR, OF_LOG_FATAL_ERROR or OF_LOG_SILENT)
So you could try something like this
ofSetLogLevel(OF_LOG_VERBOSE);
ofLog(OF_LOG_VERBOSE, "I SHOULD BE PRINTED");
ofSetLogLevel(OF_LOG_ERROR);
ofLog(OF_LOG_VERBOSE, "I SHOULD NOT BE PRINTED");
But if you only want to have some debugging or whatsoever messages, you can also go with iostream to print something in your console:
int i=4;
cout << "the value of i is " << i << endl;
That should print: “the value of i is 4”.
Hope this helps
lg.ph