RDK Documentation (Open Sourced RDK Components)
RDK Logger

Description

RDK Logger provides common logging capability for all RDK components. It is a common logging library which is based on MPEOS logging & uses log4c for formatting and supports multiple log levels.

RDK Logger Capabilities
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
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
RDK Logging Configuration

Default level of logging is ERROR. Logging settings are configured in debug.ini
- LOG.RDK.<component1> = FATAL ERROR WARNING NOTICE INFO
- LOG.RDK.<component2> = FATAL ERROR WARNING NOTICE INFO DEBUG
Logging Levels supported by RDK Logger.
Code Description
RDK_LOG_FATAL Any error that is forcing a shutdown of the service or application to prevent data loss (or further data loss), reserve these only for the most heinous errors and situations where there is guaranteed to have been data corruption or loss.
RDK_LOG_ERROR Any error which is fatal to the operation but not the service (cant open a file, missing data, etc)
RDK_LOG_WARN Anything that can potentially cause application oddities, but for which the application automatically recoverring.
RDK_LOG_NOTICE Anything that largely superfluous for application-level logging.
RDK_LOG_INFO Generally useful information to log (service start/stop, configuration assumptions, etc).
RDK_LOG_DEBUG Information that is diagnostically helpful to people more than just developers.
RDK_LOG_TRACE1, RDK_LOG_TRACE2,... Only when it would be "tracing" the code and trying to find one part of a function specifically.
How log files are upload to server

Modules

 RDK Logger APIs
 Describe the details about RDK debug APIs specifications.
 
 RDK Logger Utils APIs
 Describe the details about RDK Logger utils API specifications.
 
RDK_LOG
#define RDK_LOG
Definition: rdk_debug.h:258
rdk_LogLevel
rdk_LogLevel
These values represent the logging 'levels' or 'types', they are each independent.
Definition: rdk_debug.h:157
TRUE
#define TRUE
Defines for TRUE/FALSE/ENABLE flags.
Definition: wifi_common_hal.h:199