From 6be36cfce038fbddebe3734dbe177cc3d2ed7258 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Thu, 29 Feb 2024 18:22:01 +0100 Subject: [PATCH 1/4] feat(android): more log output --- .../runtime/v8/src/native/modules/APIModule.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/android/runtime/v8/src/native/modules/APIModule.cpp b/android/runtime/v8/src/native/modules/APIModule.cpp index 669be7264ca..d38e3cbf3eb 100644 --- a/android/runtime/v8/src/native/modules/APIModule.cpp +++ b/android/runtime/v8/src/native/modules/APIModule.cpp @@ -115,7 +115,19 @@ void APIModule::logInfo(const FunctionCallbackInfo& args) Isolate* isolate = args.GetIsolate(); HandleScope scope(isolate); v8::String::Utf8Value message(isolate, APIModule::combineLogMessages(args)); - APIModule::logInternal(LOG_LEVEL_INFO, LCAT, *message); + + std::string cppStr(*message); + + int maxChunk = 4050; + int chunkCount = cppStr.length() / maxChunk; + for (int i = 0; i <= chunkCount; i++) { + int max = maxChunk * (i + 1); + if (max >= cppStr.length()) { + APIModule::logInternal(LOG_LEVEL_INFO, LCAT, cppStr.substr(maxChunk * i).c_str()); + } else { + APIModule::logInternal(LOG_LEVEL_INFO, LCAT, cppStr.substr(maxChunk * i , max).c_str()); + } + } } void APIModule::logWarn(const FunctionCallbackInfo& args) From 8abede7a5fd1a4e1a78887fb10725509d40ce73c Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Sun, 4 Aug 2024 19:17:09 +0200 Subject: [PATCH 2/4] remove if --- android/runtime/v8/src/native/modules/APIModule.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/android/runtime/v8/src/native/modules/APIModule.cpp b/android/runtime/v8/src/native/modules/APIModule.cpp index 0c761b75d61..9047f8fef43 100644 --- a/android/runtime/v8/src/native/modules/APIModule.cpp +++ b/android/runtime/v8/src/native/modules/APIModule.cpp @@ -122,11 +122,7 @@ void APIModule::logInfo(const FunctionCallbackInfo& args) int chunkCount = cppStr.length() / maxChunk; for (int i = 0; i <= chunkCount; i++) { int max = maxChunk * (i + 1); - if (max >= cppStr.length()) { - APIModule::logInternal(LOG_LEVEL_INFO, LCAT, cppStr.substr(maxChunk * i).c_str()); - } else { - APIModule::logInternal(LOG_LEVEL_INFO, LCAT, cppStr.substr(maxChunk * i , max).c_str()); - } + APIModule::logInternal(LOG_LEVEL_INFO, LCAT, cppStr.substr(maxChunk * i , max).c_str()); } } From 5942c46e1da93bed0eb64ee4f8457816708fea17 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Sun, 4 Aug 2024 19:34:10 +0200 Subject: [PATCH 3/4] change for loop --- android/runtime/v8/src/native/modules/APIModule.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/android/runtime/v8/src/native/modules/APIModule.cpp b/android/runtime/v8/src/native/modules/APIModule.cpp index 9047f8fef43..d443bc4c77f 100644 --- a/android/runtime/v8/src/native/modules/APIModule.cpp +++ b/android/runtime/v8/src/native/modules/APIModule.cpp @@ -119,10 +119,8 @@ void APIModule::logInfo(const FunctionCallbackInfo& args) std::string cppStr(*message); int maxChunk = 4050; - int chunkCount = cppStr.length() / maxChunk; - for (int i = 0; i <= chunkCount; i++) { - int max = maxChunk * (i + 1); - APIModule::logInternal(LOG_LEVEL_INFO, LCAT, cppStr.substr(maxChunk * i , max).c_str()); + for (int i = 0; i < cppStr.length(); i+=maxChunk) { + APIModule::logInternal(LOG_LEVEL_INFO, LCAT, cppStr.substr(i , maxChunk).c_str()); } } From 9154d046612c3728f5cd6318d8b44a503b46c297 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Sun, 4 Aug 2024 22:29:13 +0200 Subject: [PATCH 4/4] Update android/runtime/v8/src/native/modules/APIModule.cpp Co-authored-by: Chris Barber --- android/runtime/v8/src/native/modules/APIModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/runtime/v8/src/native/modules/APIModule.cpp b/android/runtime/v8/src/native/modules/APIModule.cpp index d443bc4c77f..c460ac87dc2 100644 --- a/android/runtime/v8/src/native/modules/APIModule.cpp +++ b/android/runtime/v8/src/native/modules/APIModule.cpp @@ -119,7 +119,7 @@ void APIModule::logInfo(const FunctionCallbackInfo& args) std::string cppStr(*message); int maxChunk = 4050; - for (int i = 0; i < cppStr.length(); i+=maxChunk) { + for (size_t i = 0, len = cppStr.length(); i < len; i+=maxChunk) { APIModule::logInternal(LOG_LEVEL_INFO, LCAT, cppStr.substr(i , maxChunk).c_str()); } }