Description
Provides common logging capability for all RDK components.
Capabilities
- 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
Used By
All RDK Components
Uses
IARM
log4c
Used in Features
All
Interfaces
link to SVN or published/generated documentation
Owner
Hong Li
Code
Current Version - none
Change History - none
Known issues - none
OCAP RI Logs
By default, stdout is redirected to /opt/logs/ocapri_log.txt for OCAP RI related logs.
Initialization
- rdk_logger_init() loads entries from “debug.ini” and initializes log4c.
- Sets log level of the module corresponding to environment variables.
- Sets log level to default log levels, for the modules not having entries in configuration file. (Currently it is set as LOG.RDK.DEFAULT = ERROR in debug.ini)
Logging Configuration
Default level of logging is ERROR. But Logging settings are configured in debug.ini
LOG.RDK.<component1> = FATAL ERROR WARNING NOTICE INFO
LOG.RDK.<component2> = FATAL ERROR WARNING NOTICE INFO DEBUG
Log Levels
- RDK_LOG_FATAL
- RDK_LOG_ERROR
- RDK_LOG_WARN
- RDK_LOG_NOTICE
- RDK_LOG_INFO
- RDK_LOG_DEBUG
- RDK_LOG_TRACE1
- RDK_LOG_TRACE2
- RDK_LOG_TRACE3
- RDK_LOG_TRACE4
- RDK_LOG_TRACE5
- RDK_LOG_TRACE6
- RDK_LOG_TRACE7
- RDK_LOG_TRACE8
- RDK_LOG_TRACE9
Usage
Use RDK_LOG debug message as.
RDK_LOG (rdk_LogLevel level, const char *module, const char *format,...)
Here,
- "level" is Log level of the log message (FATAL, ERROR etc}
- "module" is a Module in which this message belongs to (Use module name same as mentioned in debug.ini)
- "format" is a printf style string containing the log message.
Example:
The debug messages for "INBSI" module
RDK_LOG (RDK_LOG_NOTICE, "LOG.RDK.INBSI","<%s: %s>: Sending PMT_ACQUIRED event\n", PSIMODULE, __FUNCTION__);
Here,
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 Output:
131011-21:21:49.578394 [mod=INBSI, lvl=NOTICE] [tid=4141] <SITP_PSI: NotifyTableChanged>: Sending PMT_ACQUIRED event
This way user make use of the logger in the respective modules and control the logging levels through configuration file.
Here, No need to build rdklogger again for the addition of new components/module.
Note:
Now, "mediaframework/qamsource/debug.ini" is no more in use, instead "rdklogger/debug.ini" is used and it gets copied to "/mnt/nfs/env"
How to add the rdklogger functionality to the new module
- Include rdk_debug.h header file and make use of RDK_LOG for printing logs.
- Initialize rdklogger 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
Gstreamer Logging
- 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.