Mapping ofLog to other logs

I guess this is a very common practice.
Let’s say we are using many libraries and we want to manage all of them from ofLog. eg. changing log levels at once or getting different prefix for each library.

Is there an standard way of mapping/syncing logs? or is it that usually one makes use of every log system separately?

Hi Jordi,

From the ofLog documentation:

You can call ofSetLogLevel() to set the logging level for all libraries, or set it per module.

ofSetLogLevel(OF_LOG_WARNING);
ofSetLogLevel("Library1", OF_LOG_VERBOSE);

As for the prefix for each library:

ofLogWarning("Library1") << "Logging data";
//[warning] Library1: Logging data

I understand this part. But i don’t know how to route all the messages from the library to ofLog. The libary is not writen by myself and it throws log messages from many different places in the code base… i can’t/want to change those… I thought there could be a magic way to route the messages to ofLog before the are thrown to the console… but maybe im asking for something that does not exist…

I thought about something like:

#define LIBRARY_WARNING ofLogWarning(string(__func__))

but not sure how that would work…

Oh I understand what you mean now.

I’ve found this post http://www.qtforum.org/article/678/redirecting-cout-cerr-to-qdebug.html, in which the cout and cerr are redirected to qDebug.

I think a similar thing can be done with ofLog

Thank you! i’ll have a look!