ofLog example

I’m curious what the new ofLog does in 006. By looking at the code, I can’t really tell. Is there an example of a description of what the log functions do? Are they able to log printfs to file?

I think it’s basically just a way to centralize console output. Instead of everyone doing their own willy-nilly couts and printfs to the console, if you pass it through the ofLog function, it allows standardization of the messages.

An example of the benefit of this is the log level functionality which allows you to filter how verbose your console is going to be. Basically you use the ofSetLogLevel(int logLevel) to specify the lowest level of log messages you’d like to see… so setting to OF_LOG_VERBOSE, you will get all messages… setting to OF_LOG_SILENT, you will get no messages.

It’s up to the caller of ofLog() to specify what level the message is.

Here are the log levels (defined in ofConstants.h):

enum ofLogLevel{  
	OF_LOG_SILENT	//this one is special and should always be last - set ofSetLogLevel to OF_SILENT to not recieve any messages  

Potential other benefits might be redirection of the output to a log file, or formatting of the messages.

I think it’d be really cool to turn the ofLog functionality into an actual class (vs just straight printf’ing) that would cache the messages and then make them available to other objects (or leave them protected and use polymorphism to customize it). This could allow us to build a console right into our app’s GUI’s and things along those lines.

Maybe this is something I will start hacking on in my spare time :slight_smile:

Hope this helps!