[wpe-webkit] Javascript console with Cog and WPE WebKit

Adrian Perez de Castro aperez at igalia.com
Tue Aug 27 05:33:36 PDT 2019


Hello everybody,

On Tue, 27 Aug 2019 13:54:17 +0200, Enrique Ocaña González <eocanha at igalia.com> wrote:
> El martes, 27 de agosto de 2019 13:30:01 (CEST) Andy Pont escribió:
> 
> > I have an i.MX6 Yocto build that is running Cog and WPE WebKit to
> > provide the front end UI. I don't seem to be able to find how to enable
> > or where the console.log() messages in any Javascript gets output. Can
> > anyone point me in the right direction?
> 
> I'm sure somebody will answer this thread with the right way to do it, but if 
> that's not the case and you still need to get the console logs no matter what, 
> just try this small hack I use sometimes when doing local debugging:
> 
> Change this line of code
> 
> https://github.com/WebKit/webkit/blob/master/Source/WebKit/UIProcess/API/C/
> WKPreferences.cpp#L1225
>
> […]

Please do NOT use the plain C API, because it has been removed and is not
available by in official releases.

If you are using the Cog launcher (the “cog” binary), the properties of
the “WebKitSettings” class [1] are exposed as command line options, see:

  % cog --help-websettings|grep console
    --enable-write-console-messages-to-stdout=BOOL       Whether to write console messages on stdout

So you can enable this launching Cog with the option enabled:

  % cog --enable-write-console-messages-to-stdout=1 […]

If you are using “libcogcore” to build your own launcher, you can use the
“webkit_settings_set_enable_write_console_messages_to_stdout()” [1] in your
code. The public (and supported) API has you covered there.

You can also see console messages in the “Console” tab of the remote Web
Inspector [2]. Note that you will need a WebKitGTK-based browser running
on your desktop (like GNOME Web) to connect to WPE WebKit web views, make
sure both are the same release (e.g. 2.24.x).

Last but not least, if you want to have total control over how console
messages get logged, you can write a WebProcess extension and connect
to the “WebKitWebPage:console-message-sent” signal [3], and write your
own C/C++ code to handle the messages (you could, for example, log errors
to syslog, the systemd journal, or any other approach that suits your
use-case).

I hope this helps :)

Cheers,
—Adrián

---
[1] https://wpewebkit.org/reference/wpewebkit/unstable/WebKitSettings.html
[2] https://blogs.igalia.com/carlosgc/2017/05/03/webkitgtk-remote-debugging-in-2-18/
[3] https://wpewebkit.org/reference/wpewebkitwebextensions/unstable/WebKitWebPage.html#WebKitWebPage-console-message-sent
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.webkit.org/pipermail/webkit-wpe/attachments/20190827/7ef42ece/attachment.bin>


More information about the webkit-wpe mailing list