RDK Logger is a general-purpose logging mechanism for RDK components. It supports multiple log levels and modules, with log levels configured via a configuration file (debug.ini). Each module can have its own log level, and these can be changed at runtime using the provided CLI utility.
- Abstracts logging client from underlying logging utility.
- Dynamically enables/disables logging level at run time.
- Provides a structured log format including timestamp, module name, log level, and message.
- Controls log level independently for each component/module.
- Enables logging globally via a single configuration value.
- Controls initial log level for each component/module from configuration file (
debug.ini) at startup. - Prints formatted data to stdout or log files.
- Supports separate log files for each module if configured.
Logging levels and modules are configured in debug.ini. If a module is not explicitly configured in debug.ini, it inherits the log level from LOG.RDK.DEFAULT.
See debug.ini.sample for an example configuration file.
The sample file includes comments explaining how to set log levels for each module and what each log level enables.
For example:
LOG.RDK.DEFAULT=WARNING
LOG.RDK.FOO=DEBUG
LOG.RDK.BAR=NONE
- The component
FOOwill print DEBUG, INFO, WARNING, ERROR, and FATAL messages - The component
BARprintsnothing - All the other components prints WARNING and higher log levels like ERROR, and FATAL as defined by
DEFAULT
Use the rdklogctrl utility to change log levels for modules at run time.
# Set log level for a module
rdklogctrl <process_name> <module_name> <log_level>
# Examples
rdklogctrl myapp LOG.RDK.NETWORK DEBUG
rdklogctrl receiver LOG.RDK.AUDIO INFO
# Available levels: FATAL, ERROR, WARN, NOTICE, INFO, DEBUG, TRACE, NONE#include "rdk_logger.h"int main() {
// Initialize logger
if (RDK_LOGGER_INIT() != RDK_SUCCESS) {
fprintf(stderr, "Failed to initialize RDK Logger\n");
return -1;
}
// Log messages
RDK_LOG(RDK_LOG_INFO, "LOG.RDK.MYAPP", "Application started\n");
RDK_LOG(RDK_LOG_ERROR, "LOG.RDK.MYAPP", "Error: %s\n", strerror(errno));
// Cleanup
rdk_logger_deinit();
return 0;
}gcc myapp.c -lrdkloggers -llog4c -lglib-2.0This repository includes comprehensive documentation for all aspects of RDK Logger:
π API Documentation
Complete developer reference
- Detailed API function documentation with parameters and return values
- Architecture overview and capabilities
- Configuration system and debug.ini format
- Runtime control mechanisms and utilities
- Performance optimization and best practices
- Complete real-world examples and usage patterns
β‘ Quick Reference
Essential information for daily use
- Core function syntax and common patterns
- Log level hierarchy and usage guidelines
- Configuration snippets and examples
- Runtime control commands (rdklogctrl)
- Build system integration examples
- Debugging tips and test programs
π Migration Guide
Transitioning from other logging systems
- Step-by-step migration from printf/fprintf, syslog, and custom logging
- Log level mapping between different systems
- Configuration conversion techniques
- Common migration pitfalls and solutions
- Validation scripts and testing approaches
π οΈ Troubleshooting Guide
Solutions for common issues
- Initialization failures and configuration problems
- Missing log output debugging
- Runtime control issues
- Performance and memory problems
- Multi-threading complications
- Build and linking solutions
- Read the Quick Start section above
- Study API Documentation for comprehensive understanding
- Reference Quick Reference for daily syntax needs
- Identify your current logging system in Migration Guide
- Follow the step-by-step migration process
- Validate using provided migration scripts and tests
- Check Troubleshooting Guide for your specific issue
- Use debugging techniques and tools provided
- Reference Quick Reference for correct syntax
| Level | When to Use |
|---|---|
| FATAL | System crash, unusable |
| ERROR | Operation failures |
| WARN | Potential problems |
| NOTICE | Important events |
| INFO | General information |
| DEBUG | Debugging details |
| TRACE | Function tracing |
- liblog4c-dev - Log4C development headers
- libglib2.0-dev - GLib development headers
- autotools - For building from source
rdk_logger/
βββ include/ # Header files (rdk_logger.h, etc.)
βββ src/ # Source files
βββ utils/ # Utility programs (rdklogctrl)
βββ test/ # Test programs
βββ unittests/ # Unit tests
βββ debug.ini.sample # Example configuration
βββ docs/ # Comprehensive documentation