RDKB-65004: Code changes from OpenSpec proposal#59
Open
jayasrikadiyal wants to merge 1 commit into
Open
Conversation
| return 1; | ||
| } | ||
| snprintf(tmp_path, tmp_path_len, "%s.dedup", input_path); | ||
| tmp_output = fopen(tmp_path, "w"); |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a duplicate log message suppression (“dedup”) feature to rdk_logger (plus a standalone log-file filter) to reduce repeated log volume on RDK-B devices, configured via debug.ini.
Changes:
- Introduces a new dedup engine (
src/rdk_log_dedup.c+src/include/rdk_log_dedup.h) and wires it into the log dispatch path. - Adds
debug.iniconfiguration keys for enabling and tuning the dedup window/max suppression. - Adds a standalone
rdk_log_dedup_filterutility and new unit tests for the dedup engine.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
src/include/rdk_log_dedup.h |
Declares dedup config/state types and dedup API used by the logger. |
src/rdk_log_dedup.c |
Implements the dedup hashing/state tracking and suppression/summary behavior. |
src/rdk_debug_priv.c |
Integrates dedup into rdk_dbg_priv_log_msg() and parses dedup config keys from debug.ini. |
src/Makefile.am |
Adds the dedup implementation source to the logger library build. |
utils/rdk_log_dedup_filter.c |
Adds a standalone tool to filter consecutive duplicates in log files (optionally in-place). |
utils/Makefile.am |
Adds the new filter tool target to the utils build. |
debug.ini.sample |
Documents the new dedup configuration keys. |
unittests/rdkLoggerDedupTest.cpp |
Adds unit tests covering dedup enable/disable and suppression behavior. |
unittests/CMakeLists.txt |
Adds the new dedup test to the unit test build. |
Comments suppressed due to low confidence (1)
unittests/CMakeLists.txt:48
rdkLoggerDedupTest.cppincludesrdk_log_dedup.h, which lives undersrc/include/. The unit test CMake currently only adds installed include directories, so the new test will fail to compile unlesssrc/includeis on the include path (the header is not installed viainclude/Makefile.am).
Add the repository’s src/include directory to the test include paths.
rdkLoggerDedupTest.cpp
main.cpp
)
include_directories(${CMAKE_INSTALL_PREFIX}/include)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
308
to
+312
| } | ||
| } | ||
| } | ||
|
|
||
| /* Parse dedup configuration keys */ |
Comment on lines
+159
to
+161
| /* Check if this is a duplicate of the previous message */ | ||
| if (slot->repeat_count > 0 && slot->last_msg_hash == msg_hash) | ||
| { |
| if ((now - slot->first_seen) >= (time_t)g_dedup_config.window_sec) | ||
| { | ||
| /* Window expired - flush summary and allow this message */ | ||
| fprintf(stderr, "Previous message repeated %u times\n", slot->repeat_count); |
Comment on lines
+175
to
+178
| if (slot->repeat_count >= g_dedup_config.max_suppress) | ||
| { | ||
| /* Max reached - flush and allow */ | ||
| fprintf(stderr, "Previous message repeated %u times\n", slot->repeat_count); |
Comment on lines
+192
to
+197
| /* Different message or first message */ | ||
| if (slot->repeat_count > 0) | ||
| { | ||
| /* Emit summary for previous suppression run */ | ||
| fprintf(stderr, "Previous message repeated %u times\n", slot->repeat_count); | ||
| } |
Comment on lines
+165
to
+167
| /* Window expired - flush summary and allow this message */ | ||
| fprintf(stderr, "Previous message repeated %u times\n", slot->repeat_count); | ||
| slot->repeat_count = 0; |
Comment on lines
+34
to
+38
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> |
| fclose(input); | ||
| return 1; | ||
| } | ||
| output = tmp_output; |
| { | ||
| /* Window expired - flush summary and allow this message */ | ||
| fprintf(stderr, "Previous message repeated %u times\n", slot->repeat_count); | ||
| slot->repeat_count = 0; |
| { | ||
| /* Max reached - flush and allow */ | ||
| fprintf(stderr, "Previous message repeated %u times\n", slot->repeat_count); | ||
| slot->repeat_count = 0; |
| /* Process lines */ | ||
| while (fgets(line, sizeof(line), input) != NULL) | ||
| { | ||
| const char *content = strip_timestamp(line); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds duplicate log message suppression to rdk_logger to reduce logging volume and log uploads from RDK-B devices.
Changes:
Key Design:
Jira: RDKB-65004