Rebase - #45
Conversation
Co-authored-by: Saranya <saranya_elango@comcast.com> Co-authored-by: nhanasi <navihansi@gmail.com>
Reason for change: Refactor the RDKLogger component in such a way that, 1. The config file debug.ini is only for the override; 2. Must log even if new module not present in debug.ini 3. The config file must say only the specific level; not individual log levels 4. Default loglevel must be based on LOG.RDK.DEFAULT 5. Remove log4crc overrides Test Procedure: Tested and verified Risks: Medium Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com> Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com> Co-authored-by: Karunakaran A <48997923+karuna2git@users.noreply.github.com>
Release of RDKLogger v2.0.0
Reason for change: Refactor the RDKLogger component in such a way that, 1. The config file debug.ini is only for the override; 2. Must log even if new module not present in debug.ini 3. The config file must say only the specific level; not individual log levels 4. Default loglevel must be based on LOG.RDK.DEFAULT 5. Remove log4crc overrides Test Procedure: Tested and verified Risks: Medium Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com> Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com> Co-authored-by: Karunakaran A <48997923+karuna2git@users.noreply.github.com>
Release of RDKLogger v2.0.0
* RDKB-60970: RDKLogger OpenSource Migration Reason for change: To fix compilation errors Test Procedure: Tested and verified Risks:Medium Priority:P1 Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com> Signed-off-by: karunakaran_amirthalingam <karunakaran_amirthalingam@cable.comcast.com>
Release of RDKLogger v2.1.0
* RDKB-60970: RDKLogger OpenSource Migration Reason for change: To fix compilation errors Test Procedure: Tested and verified Risks:Medium Priority:P1 Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com> Signed-off-by: karunakaran_amirthalingam <karunakaran_amirthalingam@cable.comcast.com>
Release of RDKLogger v2.1.0
* Add new API to convert string log_level to type rdk_logLevel * Resolve warnings from code * Update rdk_dynamic_logger.c --------- Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com> Signed-off-by: Karunakaran A <Karunakaran_Amirthalingam@cable.comcast.com>
* Add new API to convert string log_level to type rdk_logLevel * Resolve warnings from code * Update rdk_dynamic_logger.c --------- Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com> Signed-off-by: Karunakaran A <Karunakaran_Amirthalingam@cable.comcast.com>
Release of v2.2.0 Signed-off-by: kamirt573_comcast <karunakaran_amirthalingam@cable.comcast.com>
Release of v2.2.0 Signed-off-by: kamirt573_comcast <karunakaran_amirthalingam@cable.comcast.com>
Reason for change: Add rdk_dbg_* APIs for Backward Compatibility Test Procedure: Verify WiFi Motion Risks: Low Signed-off-by: dshett549 DEEPTHICHANDRASHEKAR_SHETTY@comcast.com Co-authored-by: Deepthi C Shetty <115452109+dshett549@users.noreply.github.com>
* Updated the documentation Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com>
Reason for change: Add rdk_dbg_* APIs for Backward Compatibility Test Procedure: Verify WiFi Motion Risks: Low Signed-off-by: dshett549 DEEPTHICHANDRASHEKAR_SHETTY@comcast.com Co-authored-by: Deepthi C Shetty <115452109+dshett549@users.noreply.github.com>
* Updated the documentation Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com>
Release of v2.3.0 Signed-off-by: kamirt573_comcast <karunakaran_amirthalingam@cable.comcast.com>
Deploy cla action
Deploy fossid_integration_stateless_diffscan_target_repo action
Reason for change: Post Code Coverage in the PR workflow Test Procedure: Tested and verified Risks: Low Signed-off-by: Rose Mary Benny RoseMary_Benny@comcast.com
Reason for change: for optimization Test Procedure: Tested and verified Risks:Medium Priority:P1
Update CODEOWNERS
Signed-off-by: kamirt573_comcast <karunakaran_amirthalingam@cable.comcast.com>
…he PR as Comment (#37) * RDKEMW-9545 : Post Code Current Coverage & the latest in the PR as Comment Reason for change: Post Code Current Coverage & the latest in the PR as Comment Test Procedure: Tested and verified Risks: Low Signed-off-by: RoseMary_Benny@comcast.com <RoseMary_Benny@comcast.com>
… output type (#41) * RDKEMW-10792: Extending logger_init function to set level, format and output type Reason for change: Extending logger_init function to set level, format and output type Risks:Medium Priority:P1 Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com> Co-authored-by: Karunakaran A <48997923+karuna2git@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Reason for change: 1. Added support for syslog 2. Added support for systemd_journal 3. Added explicit support for file capture 4. Added different formatting capability 5. Added Dynamic re-configuration of format, output handler Risks:Medium Priority:P1 Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com>
Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com>
Reason for change: To support legacy systems that uses AUTOREV - Added milestone log location - Added `comcast_dated` format Risks:Medium Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com>
Reason for change: To support legacy systems that uses AUTOREV - Added milestone log location - Added `comcast_dated` format - Added legacy MACRO Risks:Medium Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com>
There was a problem hiding this comment.
Pull request overview
This pull request performs a significant refactoring of the RDK Logger library, modernizing the codebase and improving its architecture.
Changes:
- Refactored logging infrastructure to use log4c more effectively with improved category management and thread safety
- Added extensive unit test coverage including rotation, performance, error handling, and configuration tests
- Removed deprecated dynamic logger test and simplified build configuration
Reviewed changes
Copilot reviewed 70 out of 70 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| utils/rdklogctrl.c | Fixed spelling error "Reciever" → "Receiver", simplified log level validation, removed obsolete module validation |
| utils/rdk_logger_onboard_main.c | Simplified onboard logging by removing intermediate buffer and passing format string directly |
| utils/Makefile.am | Updated build flags, added LOG4C_LIBS, changed all programs to use += operator, fixed library paths |
| unittests/* | Added comprehensive test suites for ext_init, rotation, performance, error handling, and configuration |
| src/rdk_logger_init.c | Major refactor with thread safety (pthread mutex), constructor initialization, and ext_init support |
| src/rdk_debug_priv.c | Complete rewrite of logging infrastructure with new layout/appender system and improved formatting |
| src/rdk_dynamic_logger.c | Simplified dynamic logging with removal of negation support and cleaner log level handling |
| src/rdk_debug.c | Simplified public API, removed complex module number tracking, added level_from_string converter |
| test/* | Removed deprecated dynamic logger test, updated test program with new ext_init API usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| wget https://sourceforge.net/projects/log4c/files/log4c/1.2.3/log4c-1.2.3.tar.gz | ||
| tar -xzf log4c-1.2.3.tar.gz | ||
| cd "log4c-1.2.3" | ||
| ./configure "--prefix=${INSTALL_PREFIX}" | ||
| make | ||
| make install |
There was a problem hiding this comment.
This build script downloads and executes third-party source code (log4c-1.2.3.tar.gz from SourceForge) without any integrity verification, which exposes the CI/build environment to a supply-chain attack if the remote artifact or distribution channel is compromised. An attacker who can tamper with that tarball could gain code execution in your build environment (with access to build secrets and artifacts) when ./configure, make, and make install are run. To mitigate this, pin the dependency to a specific immutable artifact and verify its integrity before building (for example, by checking a known-good cryptographic hash or signature) instead of trusting the remote download implicitly.
Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com>
…54) Reason for change: 1. Removed Log split & truncation 2. Configured default buffer size to be 0 as same as Previous Releases 3. Added new log formats as TID & TS_TIDs 4. Added testApp to measure CPU 5. Updated default logging to console instead of recently changes syslog 6. Added unit test cases to verify the new formats 7. Added unified log function to handle all the log formats Test Procedure: Verify huge data Risks: Medium Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 71 out of 71 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reason for change: Move the log4c init to logger init Test Procedure: Verify logging Risks: Medium Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com>
Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 71 out of 71 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| rdk_Error rdk_logger_deinit() | ||
| { | ||
| if(isLogInited) | ||
| pthread_mutex_lock(&gInitMutex); | ||
| if (isLogInited) | ||
| { | ||
| //rdk_dbgDeinit(); | ||
| rdk_dyn_log_deInit(); | ||
| //rdk_dbg_priv_DeInit(); | ||
| rdk_logger_env_rem_conf_details(); | ||
| log4c_fini(); | ||
| //isLogInited = 0; | ||
| rdk_dyn_log_deinit(); | ||
| } |
There was a problem hiding this comment.
rdk_logger_deinit() closes the dynamic logger socket but never resets isLogInited (and doesn't call any logger/log4c deinit). After a deinit(), subsequent rdk_logger_init() calls will be a no-op, leaving dynamic logging disabled and preventing reconfiguration. Either (a) make deinit symmetrical (call rdk_dbg_priv_deinit(), set isLogInited=false, and clean up resources), or (b) if deinit is intentionally a no-op, avoid closing the dynamic logger socket and/or document that deinit does not permit re-init.
| // Extended initialization with file logging | ||
| rdk_logger_ext_config_t config = { | ||
| .fileName = "app.log", | ||
| .logdir = "/var/log/", | ||
| .maxSize = 1024*1024, // 1MB | ||
| .maxCount = 5 // Keep 5 files | ||
| }; | ||
| rdk_logger_ext_init(&config); |
There was a problem hiding this comment.
The rdk_logger_ext_config_t example here uses fields like .fileName, .logdir, .maxSize, .maxCount that don't exist in the current public struct (it now uses output, format, and pFilePolicy). This example won't compile and will mislead users—please update it to match the actual API.
| # Disable specific level (~ prefix) | ||
| rdklogctrl myapp LOG.RDK.NETWORK ~DEBUG |
There was a problem hiding this comment.
This doc claims rdklogctrl can disable a level using a ~ prefix (e.g. ~DEBUG), but the updated rdklogctrl implementation no longer accepts ~ and will treat it as an invalid log level. Please either restore ~ handling in the tool/protocol or remove/update this documentation.
| # Disable specific level (~ prefix) | |
| rdklogctrl myapp LOG.RDK.NETWORK ~DEBUG | |
| # Disable logging for a module (set level to NONE) | |
| rdklogctrl myapp LOG.RDK.NETWORK NONE |
| break; | ||
| case LVL_TEST: | ||
| strcpy(level_str, "~NONE"); | ||
| break; |
There was a problem hiding this comment.
This test case uses ~NONE as a log level for rdklogctrl, but rdklogctrl no longer supports ~-prefixed levels. As written, the command will fail (and the test currently ignores the system() return code), so it isn't exercising the intended behavior. Update the test to use supported levels and assert on the command exit status/output (or reintroduce ~ support if it's required).
|
|
||
|
|
||
| #ifndef _RDK_DEBUG_H_ | ||
| #ifndef _RDK_DEBUG_H |
There was a problem hiding this comment.
Header guard macro is inconsistent: #ifndef _RDK_DEBUG_H but #define _RDK_DEBUG_H_. This defeats the include guard and can cause multiple-definition / redefinition issues on repeated includes. Use the same macro name in both directives (and in the closing #endif comment).
| #ifndef _RDK_DEBUG_H | |
| #ifndef _RDK_DEBUG_H_ |
| #define RDK_LOGGER_INIT() (0 == access(DEBUG_INI_OVERRIDE_PATH_1, F_OK)) \ | ||
| ? rdk_logger_init(DEBUG_INI_OVERRIDE_PATH_1) \ | ||
| : (0 == access(DEBUG_INI_OVERRIDE_PATH_2, F_OK)) \ | ||
| ? rdk_logger_init(DEBUG_INI_OVERRIDE_PATH_2) \ | ||
| : rdk_logger_init(DEBUG_INI_NAME); |
There was a problem hiding this comment.
RDK_LOGGER_INIT() macro includes a trailing semicolon, which breaks common usage patterns like if (RDK_LOGGER_INIT() != RDK_SUCCESS) { ... } (as shown in the docs). Define it as a pure expression (no trailing ;) and consider wrapping the whole ternary in parentheses for safe use in larger expressions.
| #define RDK_LOGGER_INIT() (0 == access(DEBUG_INI_OVERRIDE_PATH_1, F_OK)) \ | |
| ? rdk_logger_init(DEBUG_INI_OVERRIDE_PATH_1) \ | |
| : (0 == access(DEBUG_INI_OVERRIDE_PATH_2, F_OK)) \ | |
| ? rdk_logger_init(DEBUG_INI_OVERRIDE_PATH_2) \ | |
| : rdk_logger_init(DEBUG_INI_NAME); | |
| #define RDK_LOGGER_INIT() ((0 == access(DEBUG_INI_OVERRIDE_PATH_1, F_OK)) \ | |
| ? rdk_logger_init(DEBUG_INI_OVERRIDE_PATH_1) \ | |
| : ((0 == access(DEBUG_INI_OVERRIDE_PATH_2, F_OK)) \ | |
| ? rdk_logger_init(DEBUG_INI_OVERRIDE_PATH_2) \ | |
| : rdk_logger_init(DEBUG_INI_NAME))) |
| static pthread_mutex_t gInitMutex = PTHREAD_MUTEX_INITIALIZER; | ||
|
|
||
| bool isLogInited = false; | ||
|
|
There was a problem hiding this comment.
isLogInited is a non-static global symbol. Since it is only used to protect internal initialization state, keeping it static avoids exporting an unnecessary symbol from the shared library and prevents accidental external linkage/ABI coupling.
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
| cpu_usage = (float)(100.0 * (double)(diff_total - diff_idle) / (double)diff_total); | ||
| } | ||
|
|
||
| FILE* file = fopen("cpu.txt", "a+"); |
| // Test very large configuration file | ||
| TEST_F(RDKLoggerConfigTest, LargeConfigFile) { | ||
| // Create a large configuration file | ||
| FILE* file = fopen("/tmp/rdk_logger_test/large.ini", "w"); |
| snprintf(long_module, sizeof(long_module), "LOG.RDK.%s", | ||
| "VERY_LONG_MODULE_NAME_THAT_EXCEEDS_NORMAL_LENGTH_AND_SHOULD_BE_HANDLED_GRACEFULLY_BY_THE_CONFIGURATION_PARSER"); | ||
|
|
||
| FILE* file = fopen("/tmp/rdk_logger_test/long_names.ini", "w"); |
* Added README.md for rdklogger * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Addressed review comment --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 72 out of 72 changed files in this pull request and generated 2 comments.
Suppressed comments (12)
include/rdk_debug.h:26
- Header guard macro is inconsistent: the file checks
_RDK_DEBUG_Hbut defines_RDK_DEBUG_H_, so the guard will not work as intended.
#ifndef _RDK_DEBUG_H
#define _RDK_DEBUG_H_
src/rdk_logger_init.c:121
rdk_logger_deinit()closes the dynamic logger socket but never resetsisLogInitedor deinitializes the underlying debug subsystem. After a deinit, subsequentrdk_logger_init()calls will not reconfigure or restart dynamic logging, and the logger state is left partially initialized.
utils/rdklogctrl.c:113app_lenandcomp_lenare written into a fixed 128-byte packet buffer without validating bounds. Long argv values can overflowbufand also truncate lengths into a single byte, producing malformed packets.
docs/QUICK_REFERENCE.md:19- The
rdk_logger_ext_config_texample uses fields (fileName,logdir,maxSize,maxCount) that do not exist in the new public struct. This example won’t compile for users following the quick reference.
// Extended initialization with file logging
rdk_logger_ext_config_t config = {
.fileName = "app.log",
.logdir = "/var/log/",
.maxSize = 1024*1024, // 1MB
docs/QUICK_REFERENCE.md:88
- The quick reference documents
rdklogctrl ... ~DEBUGto disable a specific log level, bututils/rdklogctrl.cno longer accepts the~prefix. This will mislead users.
# Disable specific level (~ prefix)
rdklogctrl myapp LOG.RDK.NETWORK ~DEBUG
unittests/rdkLoggerDynamic.cpp:117
- This test generates the log level string
~NONE, butrdklogctrlno longer supports the~prefix. Thesystem()call will fail and the test won't actually exercise the intended dynamic logger behavior.
src/rdk_dynamic_logger.c:42 rdk_dyn_log_logLevelToStringreturns string literals; the return type should beconst char *to avoid discarding const qualifiers.
src/rdk_logger_init.c:66- When
debugConfigFileis NULL, the implementation falls back toDEBUG_CONF_FILE(currently built as a relativedebug.ini). This is inconsistent withRDK_LOGGER_INIT()ininclude/rdk_logger.h(which selects /opt, /nvram, then /etc) and makesrdk_logger_init(NULL)unreliable in production and tests.
src/rdk_debug.c:118 rdk_logger_enable_logLevel()ignores theenableLogLvlparameter, so callers cannot actually disable a log level as the API contract implies. This is a behavioral change for legacy consumers and should be either implemented consistently or the API/docs updated to reflect the new semantics.
utils/rdklogctrl.c:43validate_loglevel()usesstrncmp()with fixed lengths, so values likeERROR123are accepted as valid. It also doesn't accept the common spellingWARNINGeven though other parts of the code/docs use it.
unittests/test_utils.h:20- After
fork(), the child should use_exit()rather thanexit()to avoid running parent atexit handlers / flushing shared stdio buffers twice. This can cause flaky test behavior.
unittests/rdkLoggerConfigTest.cpp:132 - This test expects
rdk_logger_init(NULL)to succeed, butunittests/rdkloggerInit.cppnow asserts the opposite and the current implementation falls back to a relativedebug.iniwhich typically won’t exist in the test working directory. The tests are inconsistent and this one will likely fail.
| ########################################################################## | ||
|
|
||
| AM_CPPFLAGS = -pthread -Wall | ||
| AM_CFLAGS = -pthread -Wall -Werror |
| rdk_LogLevel loggingLevel = (rdk_LogLevel) log_level; | ||
|
|
||
| if((loggingLevel >= RDK_LOG_FATAL) && (loggingLevel <= RDK_LOG_NONE)) | ||
| { | ||
| memcpy(comp_name,buf+(++i),comp_len); |
|
b'## WARNING: A Blackduck scan failure has been waived A prior failure has been upvoted
|
No description provided.