@@ -39,6 +39,22 @@ void Console::AttachInspectorClient(v8_inspector::JsV8InspectorClient* aInspecto
3939 inspector = aInspector;
4040}
4141
42+ void Console::SplitAndLogInChunks (std::string message) {
43+ auto messageLength = message.length ();
44+ int maxStringLength = 1000 ; // technically 1024, but let's have some room :)
45+
46+ if (messageLength < maxStringLength) {
47+ // print normally
48+ Log (" %s" , message.c_str ());
49+ } else {
50+ // split into chunks
51+ for (int i = 0 ; i < messageLength; i += maxStringLength) {
52+ std::string messagePart = message.substr (i, maxStringLength);
53+ Log (" %s" , messagePart.c_str ());
54+ }
55+ }
56+ }
57+
4258void Console::LogCallback (const FunctionCallbackInfo<Value>& args) {
4359 // TODO: implement 'forceLog' override option like android has, to force logs in prod if desired
4460 if (!RuntimeConfig.LogToSystemConsole ) {
@@ -66,7 +82,22 @@ void Console::LogCallback(const FunctionCallbackInfo<Value>& args) {
6682 ConsoleAPIType method = VerbosityToInspectorMethod (verbosityLevel);
6783 SendToDevToolsFrontEnd (method, args);
6884 std::string msgWithVerbosity = " CONSOLE " + verbosityLevelUpper + " : " + msgToLog;
69- Log (" %s" , msgWithVerbosity.c_str ());
85+
86+ SplitAndLogInChunks (msgWithVerbosity);
87+ // //Log("%s", msgWithVerbosity.c_str());
88+ // auto messageLength = msgWithVerbosity.length();
89+ // int maxStringLength = 1000; // technically 1024, but let's have some room :)
90+
91+ // if (messageLength < maxStringLength) {
92+ // // print normally
93+ // Log("%s", msgWithVerbosity.c_str());
94+ // } else {
95+ // // split into chunks
96+ // for (int i = 0; i < messageLength; i += maxStringLength) {
97+ // std::string messagePart = msgWithVerbosity.substr(i, maxStringLength);
98+ // Log("%s", messagePart.c_str());
99+ // }
100+ // }
70101}
71102
72103void Console::AssertCallback (const FunctionCallbackInfo<Value>& args) {
@@ -92,7 +123,9 @@ void Console::AssertCallback(const FunctionCallbackInfo<Value>& args) {
92123 std::string log = ss.str ();
93124
94125 SendToDevToolsFrontEnd (ConsoleAPIType::kAssert , args);
95- Log (" %s" , log.c_str ());
126+
127+ SplitAndLogInChunks (log);
128+ // Log("%s", log.c_str());
96129 }
97130}
98131
@@ -163,7 +196,8 @@ void Console::DirCallback(const FunctionCallbackInfo<Value>& args) {
163196
164197 std::string msgToLog = ss.str ();
165198 SendToDevToolsFrontEnd (ConsoleAPIType::kDir , args);
166- Log (" %s" , msgToLog.c_str ());
199+ SplitAndLogInChunks (msgToLog);
200+ // Log("%s", msgToLog.c_str());
167201}
168202
169203void Console::TimeCallback (const FunctionCallbackInfo<Value>& args) {
@@ -224,7 +258,8 @@ void Console::TimeEndCallback(const FunctionCallbackInfo<Value>& args) {
224258
225259 std::string msgToLog = ss.str ();
226260 SendToDevToolsFrontEnd (isolate, ConsoleAPIType::kTimeEnd , msgToLog);
227- Log (" %s" , msgToLog.c_str ());
261+ SplitAndLogInChunks (msgToLog);
262+ // Log("%s", msgToLog.c_str());
228263}
229264
230265void Console::AttachLogFunction (Local<Context> context, Local<Object> console, const std::string name, v8::FunctionCallback callback) {
0 commit comments