Get OpenRDK at Fast, secure and Free Open Source software downloads

edit SideBar

Logging messages on the console

Soon or later (usually, soon), you would like to print some debug messages on the text console (i.e., that black (or white) window where you run the agent. OpenRDK has those fancy colored messages, you should use that way of writing, rather than using printf or cout.

First of all, there are four kind of messages that a module can print on the console:

  • information messages (INFO), that are general information messages that should be always printed on the console (i.e., things that the user must always be aware of), these messages will be printed on a green background;
  • debug messages (DEBUG), that are messages used to debug your module, that usually make the user aware of things that are not so important if the module is working properly, these messages will be printed on a magenta background;
  • warning messages (WARNING) are important pieces of information that the user should be aware of, but are not "errors", in the sense that the agent can continue working properly, these messages will be printed on a orange background;
  • error messages (ERROR), are what their name means: errors, i.e., issues that cause your module not to work properly.

In order to print a message on the console, you should use one of the macros that rdkcore/logging/logging.h provides, e.g., RDK_DEBUG_PRINTF, RDK_INFO_STREAM, etc.

The *_PRINTF macros have a syntax similar to printf, while the *_STREAM macros have a syntax similar to that of std::stream object. Here are some examples:

RDK_INFO_PRINTF("This is an information message, will be printed on a green background");
RDK_DEBUG_PRINTF("This is a debug message, you will have a lot of these messages on your code");
RDK_WARNING_PRINTF("Use this kind of messages to warn the user of something important");
RDK_ERROR_PRINTF("Error messages state that something went wrong");

double d = 0.4345845894;
string s = "This is a string"
RDK_INFO_PRINTF("Using the *_PRINTF macros, you can write also doubles %f, strings %s, or other variables", d, s.c_str());
RDK_INFO_STREAM("The same can be said with the *_STREAM macros: a double " << d << " and a string " << s);
© 2004-2009 RoCoCo Laboratory Powered by PmWiki
Edit - History - Printable View - Recent Changes - Search
Page last modified on October 15, 2009, at 03:37 PM