Skip to content

RDKEMW-22637 : [VIPA][NativeScript][Rogers] FW request is getting tru… - #137

Open
vjain008 wants to merge 1 commit into
developfrom
topic/RDKEMW-22637
Open

RDKEMW-22637 : [VIPA][NativeScript][Rogers] FW request is getting tru…#137
vjain008 wants to merge 1 commit into
developfrom
topic/RDKEMW-22637

Conversation

@vjain008

Copy link
Copy Markdown
Contributor

…ncated in device logs

Reason for change: Logs are truncating
Test Procedure: Full log line must display
Risk: low
Priority: P1

…ncated in device logs

Reason for change: Logs are truncating
Test Procedure: Full log line must display
Risk: low
Priority: P1
Copilot AI review requested due to automatic review settings July 29, 2026 14:13
@vjain008
vjain008 requested a review from a team as a code owner July 29, 2026 14:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
}
}
Copilot AI review requested due to automatic review settings July 31, 2026 10:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 for fullMsg). For long logs this adds avoidable copies; build fullMsg once 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 += " ↵";

Copilot AI review requested due to automatic review settings July 31, 2026 12:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants