@@ -34,6 +34,22 @@ void Console::Init(Local<Context> context) {
34
34
}
35
35
}
36
36
37
+ void Console::SplitAndLogInChunks (std::string message) {
38
+ auto messageLength = message.length ();
39
+ int maxStringLength = 1000 ; // technically 1024, but let's have some room :)
40
+
41
+ if (messageLength < maxStringLength) {
42
+ // print normally
43
+ Log (" %s" , message.c_str ());
44
+ } else {
45
+ // split into chunks
46
+ for (int i = 0 ; i < messageLength; i += maxStringLength) {
47
+ std::string messagePart = message.substr (i, maxStringLength);
48
+ Log (" %s" , messagePart.c_str ());
49
+ }
50
+ }
51
+ }
52
+
37
53
void Console::LogCallback (const FunctionCallbackInfo<Value>& args) {
38
54
// TODO: implement 'forceLog' override option like android has, to force logs in prod if desired
39
55
if (!RuntimeConfig.LogToSystemConsole ) {
@@ -61,7 +77,22 @@ void Console::LogCallback(const FunctionCallbackInfo<Value>& args) {
61
77
std::string level = VerbosityToInspectorVerbosity (verbosityLevel);
62
78
v8_inspector::V8LogAgentImpl::EntryAdded (msgToLog, level, " " , 0 );
63
79
std::string msgWithVerbosity = " CONSOLE " + verbosityLevelUpper + " : " + msgToLog;
64
- Log (" %s" , msgWithVerbosity.c_str ());
80
+
81
+ SplitAndLogInChunks (msgWithVerbosity);
82
+ // //Log("%s", msgWithVerbosity.c_str());
83
+ // auto messageLength = msgWithVerbosity.length();
84
+ // int maxStringLength = 1000; // technically 1024, but let's have some room :)
85
+
86
+ // if (messageLength < maxStringLength) {
87
+ // // print normally
88
+ // Log("%s", msgWithVerbosity.c_str());
89
+ // } else {
90
+ // // split into chunks
91
+ // for (int i = 0; i < messageLength; i += maxStringLength) {
92
+ // std::string messagePart = msgWithVerbosity.substr(i, maxStringLength);
93
+ // Log("%s", messagePart.c_str());
94
+ // }
95
+ // }
65
96
}
66
97
67
98
void Console::AssertCallback (const FunctionCallbackInfo<Value>& args) {
@@ -86,7 +117,9 @@ void Console::AssertCallback(const FunctionCallbackInfo<Value>& args) {
86
117
87
118
std::string log = ss.str ();
88
119
v8_inspector::V8LogAgentImpl::EntryAdded (log , " error" , " " , 0 );
89
- Log (" %s" , log .c_str ());
120
+
121
+ SplitAndLogInChunks (log );
122
+ // Log("%s", log.c_str());
90
123
}
91
124
}
92
125
@@ -161,7 +194,8 @@ void Console::DirCallback(const FunctionCallbackInfo<Value>& args) {
161
194
std::string verbosityLevel = tns::ToString (isolate, data);
162
195
std::string level = VerbosityToInspectorVerbosity (verbosityLevel);
163
196
v8_inspector::V8LogAgentImpl::EntryAdded (msgToLog, level, " " , 0 );
164
- Log (" %s" , msgToLog.c_str ());
197
+ SplitAndLogInChunks (msgToLog);
198
+ // Log("%s", msgToLog.c_str());
165
199
}
166
200
167
201
void Console::TimeCallback (const FunctionCallbackInfo<Value>& args) {
@@ -225,7 +259,8 @@ void Console::TimeEndCallback(const FunctionCallbackInfo<Value>& args) {
225
259
std::string level = VerbosityToInspectorVerbosity (verbosityLevel);
226
260
std::string msgToLog = ss.str ();
227
261
v8_inspector::V8LogAgentImpl::EntryAdded (msgToLog, level, " " , 0 );
228
- Log (" %s" , msgToLog.c_str ());
262
+ SplitAndLogInChunks (msgToLog);
263
+ // Log("%s", msgToLog.c_str());
229
264
}
230
265
231
266
void Console::AttachLogFunction (Local<Context> context, Local<Object> console, const std::string name, v8::FunctionCallback callback) {
0 commit comments