RDKEMW-22637 : [VIPA][NativeScript][Rogers] FW request is getting tru… - #137
Open
vjain008 wants to merge 1 commit into
Open
RDKEMW-22637 : [VIPA][NativeScript][Rogers] FW request is getting tru…#137vjain008 wants to merge 1 commit into
vjain008 wants to merge 1 commit into
Conversation
…ncated in device logs Reason for change: Logs are truncating Test Procedure: Full log line must display Risk: low Priority: P1
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses device log truncation for JavaScript console.* output by splitting long console messages into multiple log lines before sending them through the native logger.
Changes:
- Build the full console message once and emit it in chunks when it exceeds a maximum length.
- Prefix chunked log lines with a
[current/total]indicator to preserve ordering.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+883
to
+896
| const std::string fullMsg = oss.str(); | ||
| constexpr size_t kMaxLogChunk = 900; // keep under device/syslog line limits | ||
|
|
||
| if (fullMsg.size() <= kMaxLogChunk) { | ||
| NativeJSLogger::log(INFO, "%s", fullMsg.c_str()); | ||
| } else { | ||
| const size_t total = (fullMsg.size() + kMaxLogChunk - 1) / kMaxLogChunk; | ||
| for (size_t i = 0; i < total; ++i) { | ||
| const size_t start = i * kMaxLogChunk; | ||
| const size_t len = std::min(kMaxLogChunk, fullMsg.size() - start); | ||
| const std::string chunk = fullMsg.substr(start, len); | ||
| NativeJSLogger::log(INFO, "[%zu/%zu] %s", i + 1, total, chunk.c_str()); | ||
| } | ||
| } |
gurpreet319
force-pushed
the
topic/RDKEMW-22637
branch
from
July 31, 2026 10:41
4d7395e to
7245a49
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (3)
src/NativeJSLogger.cpp:96
- Even with the larger stack buffer, this path will still truncate any formatted log message longer than 2047 bytes (vsnprintf will cut it). Since the PR goal is to avoid truncation, consider sizing the buffer dynamically using a sizing vsnprintf with va_copy and then formatting into a heap buffer.
const char* levelStr = logLevelNames[level];
char buffer[2048];
vsnprintf(buffer, sizeof(buffer), format, args);
printf("\n[%s] JsRuntime Thread-%d: %s\n", levelStr, threadId, buffer);
src/jsc/JavaScriptUtils.cpp:884
oss.str()is materialized multiple times (once for the remote inspector and again forfullMsg). For long logs this adds avoidable copies; buildfullMsgonce and reuse it for both the inspector and NativeJSLogger.
const std::string fullMsg = oss.str();
constexpr size_t kMaxLogChunk = 2000;
src/jsc/JavaScriptUtils.cpp:895
- Splitting one logical console message into multiple log lines can interleave with other threads’ logs and make reconstruction hard. Adding an explicit part index to each chunk (and avoiding the non-ASCII continuation marker) makes logs easier to parse and reassemble reliably.
for (size_t start = 0; start < fullMsg.size(); start += kMaxLogChunk) {
const size_t len = std::min(kMaxLogChunk, fullMsg.size() - start);
std::string chunk(fullMsg.substr(start, len));
if (start + len < fullMsg.size()) {
chunk += " ↵";
gurpreet319
force-pushed
the
topic/RDKEMW-22637
branch
from
July 31, 2026 12:22
7245a49 to
4d7395e
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/jsc/JavaScriptUtils.cpp:884
- The chunk size is set to 900 “to keep under device/syslog line limits”, but chunked log lines add a "[i/total] " prefix (and the logger may add its own prefix). As written, the emitted line length can exceed the intended limit and still truncate.
constexpr size_t kMaxLogChunk = 900; // keep under device/syslog line limits
src/jsc/JavaScriptUtils.cpp:883
- Line is indented with a tab, while surrounding code in this function uses spaces; this will likely fail style checks / create inconsistent formatting.
const std::string fullMsg = oss.str();
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.
…ncated in device logs
Reason for change: Logs are truncating
Test Procedure: Full log line must display
Risk: low
Priority: P1