@@ -39,6 +39,22 @@ void Console::AttachInspectorClient(v8_inspector::JsV8InspectorClient* aInspecto
39
39
inspector = aInspector;
40
40
}
41
41
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
+
42
58
void Console::LogCallback (const FunctionCallbackInfo<Value>& args) {
43
59
// TODO: implement 'forceLog' override option like android has, to force logs in prod if desired
44
60
if (!RuntimeConfig.LogToSystemConsole ) {
@@ -66,7 +82,22 @@ void Console::LogCallback(const FunctionCallbackInfo<Value>& args) {
66
82
ConsoleAPIType method = VerbosityToInspectorMethod (verbosityLevel);
67
83
SendToDevToolsFrontEnd (method, args);
68
84
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
+ // }
70
101
}
71
102
72
103
void Console::AssertCallback (const FunctionCallbackInfo<Value>& args) {
@@ -92,7 +123,9 @@ void Console::AssertCallback(const FunctionCallbackInfo<Value>& args) {
92
123
std::string log = ss.str ();
93
124
94
125
SendToDevToolsFrontEnd (ConsoleAPIType::kAssert , args);
95
- Log (" %s" , log .c_str ());
126
+
127
+ SplitAndLogInChunks (log );
128
+ // Log("%s", log.c_str());
96
129
}
97
130
}
98
131
@@ -163,7 +196,8 @@ void Console::DirCallback(const FunctionCallbackInfo<Value>& args) {
163
196
164
197
std::string msgToLog = ss.str ();
165
198
SendToDevToolsFrontEnd (ConsoleAPIType::kDir , args);
166
- Log (" %s" , msgToLog.c_str ());
199
+ SplitAndLogInChunks (msgToLog);
200
+ // Log("%s", msgToLog.c_str());
167
201
}
168
202
169
203
void Console::TimeCallback (const FunctionCallbackInfo<Value>& args) {
@@ -224,7 +258,8 @@ void Console::TimeEndCallback(const FunctionCallbackInfo<Value>& args) {
224
258
225
259
std::string msgToLog = ss.str ();
226
260
SendToDevToolsFrontEnd (isolate, ConsoleAPIType::kTimeEnd , msgToLog);
227
- Log (" %s" , msgToLog.c_str ());
261
+ SplitAndLogInChunks (msgToLog);
262
+ // Log("%s", msgToLog.c_str());
228
263
}
229
264
230
265
void Console::AttachLogFunction (Local<Context> context, Local<Object> console, const std::string name, v8::FunctionCallback callback) {
0 commit comments