From 6281c92d7a5afdc989a5531ea765979a6c19a010 Mon Sep 17 00:00:00 2001 From: Trupthi B P Date: Thu, 22 May 2025 11:01:11 +0530 Subject: [PATCH 1/2] Ticket Number:RDKEMW-4353:Bug when set DEBUG level Reason for change: Corrected the data type of id and resolved conflict1 Test Procedure: build should be successful. Risks: low Priority: P2 --- src/NativeJSRenderer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NativeJSRenderer.cpp b/src/NativeJSRenderer.cpp index 408c08c..b999e49 100644 --- a/src/NativeJSRenderer.cpp +++ b/src/NativeJSRenderer.cpp @@ -252,7 +252,7 @@ std::list NativeJSRenderer::getApplications() ApplicationDetails appData; appData.id = key; appData.url = value.url; - NativeJSLogger::log(DEBUG, "Found application with ID: %s and URL: %s\n", key, value.url); + NativeJSLogger::log(DEBUG, "Found application with ID: %d and URL: %s\n", key, value.url); runningApplication.push_back(appData); } } @@ -289,10 +289,10 @@ void NativeJSRenderer::createApplicationInternal(ApplicationRequest& appRequest) JavaScriptContext* context = new JavaScriptContext(features, "" , mEngine); if(NULL == context) { - NativeJSLogger::log(DEBUG, "Context not created for ID: %s\n", id); + NativeJSLogger::log(DEBUG, "Context not created for ID: %d\n", id); return ; } - NativeJSLogger::log(DEBUG, "Context created for ID: %s\n", id); + NativeJSLogger::log(DEBUG, "Context created for ID: %d\n", id); double endTime = getTimeInMilliSec(); context->setCreateApplicationStartTime(startTime); From 32f6cf11af9c786d34334838ff75065fbd0d70cf Mon Sep 17 00:00:00 2001 From: Trupthi B P Date: Thu, 22 May 2025 16:08:47 +0530 Subject: [PATCH 2/2] Ticket Number:RDKEMW-4353:Implement logs to remain Reason for change: Converted remaining cout to log statements in NativeJSRenderer.cpp file and rebased Test Procedure:Able to set log levels without any runtime errors and APIs must work Risks: low Priority: P2 --- src/NativeJSRenderer.cpp | 60 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/NativeJSRenderer.cpp b/src/NativeJSRenderer.cpp index b999e49..cfb7622 100644 --- a/src/NativeJSRenderer.cpp +++ b/src/NativeJSRenderer.cpp @@ -62,7 +62,7 @@ static size_t HeaderCallback(void *contents, size_t size, size_t nmemb, void *us mem->headerBuffer = (char*)realloc(mem->headerBuffer, mem->headerSize + downloadSize + 1); if(mem->headerBuffer == NULL) { /* out of memory! */ - std::cout << "out of memory when downloading image\n"; + NativeJSLogger::log(WARN, "Out of memory when downloading image\n"); return 0; } @@ -81,7 +81,7 @@ static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, voi mem->contentsBuffer = (char*)realloc(mem->contentsBuffer, mem->contentsSize + downloadSize + 1); if(mem->contentsBuffer == NULL) { /* out of memory! */ - std::cout << "out of memory when downloading image\n"; + NativeJSLogger::log(WARN, "Out of memory when downloading image\n"); return 0; } @@ -132,7 +132,7 @@ NativeJSRenderer::NativeJSRenderer(std::string waylandDisplay): mEngine(nullptr) if (embedThunderJS) { mEmbedThunderJS = true; - std::cout << "thunderjs enabled via environment " << std::endl; + NativeJSLogger::log(INFO, "ThunderJS enabled via environment\n"); } else { @@ -140,7 +140,7 @@ NativeJSRenderer::NativeJSRenderer(std::string waylandDisplay): mEngine(nullptr) if (f.good()) { mEmbedThunderJS = true; - std::cout << "thunderjs enabled via file presence " << std::endl; + NativeJSLogger::log(INFO, "ThunderJS enabled via file presence\n"); } } @@ -148,13 +148,13 @@ NativeJSRenderer::NativeJSRenderer(std::string waylandDisplay): mEngine(nullptr) if (f.good()) { mEmbedRdkWebBridge = true; - std::cout << "rdk webbridge enabled via file presence " << std::endl; + NativeJSLogger::log(INFO, "rdk WebBridge enabled via file presence\n"); } char* enableWebSocketServer = getenv("NATIVEJS_ENABLE_WEBSOCKET_SERVER"); if (enableWebSocketServer) { mEnableWebSocketServer = true; - std::cout << "websocket server enabled via environment " << std::endl; + NativeJSLogger::log(INFO, "WebSocket server enabled via environment\n"); } else { @@ -162,7 +162,7 @@ NativeJSRenderer::NativeJSRenderer(std::string waylandDisplay): mEngine(nullptr) if (f.good()) { mEnableWebSocketServer = true; - std::cout << "websocket server enabled via file presence " << std::endl; + NativeJSLogger::log(INFO, "WebSocket server enabled via file presence\n"); } } } @@ -189,12 +189,12 @@ void NativeJSRenderer::setEnvForConsoleMode(ModuleSettings& moduleSettings) JavaScriptContext* context = new JavaScriptContext(features, "", mEngine); if (!context) { - std::cout << "Context could not be initialized - exiting" << std::endl; - return; + NativeJSLogger::log(ERROR, "Context could not be initialized - exiting\n"); + return; } mConsoleState->consoleContext = context; - std::cout << "Running developer console..." << std::endl; + NativeJSLogger::log(INFO, "Running developer console...\n"); std::thread consoleThread(&JsRuntime::NativeJSRenderer::runDeveloperConsole, this, std::ref(mConsoleState->moduleSettings)); consoleThread.detach(); @@ -244,7 +244,7 @@ std::list NativeJSRenderer::getApplications() std::list runningApplication; if(mContextMap.empty()) { - std::cout<<"No application found.. "<runFile(url.c_str(), nullptr, true); - std::cout << "test application execution result " << ret << std::endl; + NativeJSLogger::log(INFO, "Test application execution result: %d\n", ret ? 1 : 0); double duration = context->getExecutionDuration(); context->setAppdata(id, url); - NativeJSLogger::log(INFO, "Execution duration(runApplicationDuration) for ID %d | URL %s : %.3f ms\n", id, url.c_str(), duration); + NativeJSLogger::log(INFO, "Execution duration(runApplicationDuration) for ID %d | URL %s : %.3f ms\n", id, url.c_str(), duration); } } else{ - std::cout << "nativeJS application url not proper" << std::endl; + NativeJSLogger::log(WARN, "nativeJS application url not proper\n"); return ; } } @@ -364,7 +364,7 @@ void NativeJSRenderer::runJavaScriptInternal(ApplicationRequest& appRequest) mContextMap[id].url = code; if(!code.empty()) { - std::cout<<"Running the JavaScript code "< runScript(rawcode.c_str(),true,"JavaScriptCode",nullptr,true); @@ -372,7 +372,7 @@ void NativeJSRenderer::runJavaScriptInternal(ApplicationRequest& appRequest) NativeJSLogger::log(INFO, "Execution duration(runJavaScriptDuration) for ID %d | %s : %.3f ms\n", id, code.c_str(), duration); } else{ - std::cout<<"Empty/Invalid JavaScript Code"<