我可以通过更改onConsoleMessageAdded
文件中的功能来解决此问题ios.ts
更新了一段代码
let message = msg.params.message;
let type;
let method = "Runtime.consoleAPICalled";
if(message.type === "log") {
switch(message.level) {
case "log": type = "log"; break;
case "info": type = "info"; break;
case "error": type = "error"; break;
default: type = "log";
}
} else {
type = message.type;
}
const consoleMessage = {
source: message.source,
level: type,
text: message.text,
lineNumber: message.line,
timestamp: (new Date).getTime(),
url: message.url,
stackTrace: message.stackTrace ? {
callFrames: message.stackTrace
} : undefined,
args:message.parameters,
networkRequestId: message.networkRequestId,
};
if(type == "error"){
method = "Log.entryAdded";
this._target.fireEventToTools(method, {entry:consoleMessage});
}else
this._target.fireEventToTools(method, consoleMessage);
return Promise.resolve(null);
}