Chrome Devtools console hides all messages from remote device

1.6k views Asked by At

I'm debugging an IOS iPad running Safari from Chrome Devtools on Linux using ios-webkit-debug-proxy and remotedebug-ios-webkit adapter.

It connects, and I can view the DOM etc, but console.log() messages do not show in the console. I can see the hidden message count increase, but I can not find a way to view the messages.

It was working initially, but has stopped. I have tried resetting devtools to default via "Settings->Preferences->Devtools->Restore defaults and reload", but no luck.

Please see the screenshot: Screenshot of chrome devtools

Any help would be appreciated.

3

There are 3 answers

2
Anurag Sharma On

I was able to fix this by making changes in onConsoleMessageAdded function in file ios.ts

Updated piece of code

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);
}
0
George Howarth On

Similar to the other answer, console.info appears to work in place of the standard console.log.

If you run console.log = console.info; before you log anything, it will work as expected.

1
MJ82 On

You can use console.error instead of console.log.