Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Abstracts logging client from underlying logging utility.
  • Dynamically enables/disables logging level at run time.
  • Provides logging format that complies with the existing OCAP format (e.g. <timestamp> [mod=*, level=*]).
  • Controls log level independently for each component/module.
  • Enables logging globally via single configuration value.
  • Controls initial log level for each component/module from configuration file (debug.ini) at startup.
  • Prints formatted data to stdout.
  • Separates logs into separate files based on "SEPARATE.LOGFILE.SUPPORT" configuration variable

How to add the RDK logger functionality to the new module?

Include rdk_debug.h header file and make use of RDK_LOG for printing logs. Initialize RDK Logger by calling rdk_logger_init() in the respective module/component. Build new module/component by linking "librdkloggers.so" along with "liblog4c.so" and "libglib-2.0.so" shared object.

  • Example: -lrdkloggers -L ../opensource/lib -llog4c -lglib-2.0


RDK Logger Usage


  • RDK_LOG (rdk_LogLevel level, const char *module, const char *format,...)
  • "level" is Log level of the log message (FATAL, ERROR etc). Apart from this there are special log levels like ALL, NONE, TRACE, !TRACE are supported.
  • "module" is the Module to which this message belongs to (Use module name same as mentioned in debug.ini)
  • "format" is a printf style string containing the log message.

All the RDK components logs are stored under /opt/log/ with a naming convention <RDK component>="">_log.txt.
For example, /opt/log/pod_log.txt includes all events logged by POD Manager module.

Sample code for Logging

For example, add a debug messages for "INBSI" module

Info

RDK_LOG (RDK_LOG_NOTICE, "LOG.RDK.INBSI","<%s: %s>: Sending PMT_ACQUIRED event\n", PSIMODULE, __FUNCTION__);


User needs to provide the module name "LOG.RDK.INBSI", which is the same as mentioned in debug.ini
$ cat debug.ini
EnableMPELog = TRUE
LOG.RDK.INBSI = ALL FATAL ERROR WARNING NOTICE INFO DEBUG


Sample logging output:
131011-21:21:49.578394 [mod=INBSI, lvl=NOTICE] [tid=4141] <SITP_PSI: NotifyTableChanged>: Sending PMT_ACQUIRED event
In this way, user make use of the RDK logger in the respective modules and control the logging levels through configuration file. Here, No need to build RDK logger again for the addition of new components/module.
How GStreamer logging
A callback function gst_debug_add_log_function() is registered to receive gstreamer logs.
Logs are converted to RDK logs in callback function.
RMF element which controls a gst-element shall register element name and corresponding log module using void RMF_registerGstElementDbgModule(char *gst_module, char *rmf_module)
Callback function uses this information to get module names corresponding to gstreamer logs.
RDK Logging architecture

Used By

All RDK Components

...

  • A callback function is registered to receive gstreamer logs.
    • gst_debug_add_log_function()
  • Logs are converted to RDK logs in callback function.
  • RMF element which controls a gst-element shall register element name and corresponding log module using
    • void RMF_registerGstElementDbgModule(char *gst_module, char *rmf_module)
  • Callback function uses this information to get module names corresponding to gstreamer logs.

 

RDK_LOG (RDK_LOG_NOTICE, "LOG.RDK.INBSI","<%s: %s>: Sending PMT_ACQUIRED event\n", PSIMODULE, __FUNCTION__);