Skip to content

Commit

Permalink
Hack into JS to get some logs in Julia
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Sep 19, 2023
1 parent d0b483c commit 1c74e41
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
15 changes: 15 additions & 0 deletions WGLMakie/src/wglmakie.bundled.js
Original file line number Diff line number Diff line change
Expand Up @@ -20636,6 +20636,21 @@ function register_popup(popup, scene, plots_to_pick, callback) {
}
});
}
function traceMethodCalls(obj) {
return new Proxy(obj, {
get (target, methodName, receiver) {
return function(...args) {
JSServe.Connection.send_to_julia({
msg_type: "4",
message: JSON.stringify(args)
});
return;
};
}
});
}
window._console = console;
window.console = traceMethodCalls(console);
window.WGL = {
deserialize_scene,
threejs_module,
Expand Down
22 changes: 22 additions & 0 deletions WGLMakie/src/wglmakie.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,28 @@ export function register_popup(popup, scene, plots_to_pick, callback) {
});
}

function traceMethodCalls(obj) {
return new Proxy(obj, {
get(target, methodName, receiver) {
// get origin method
return function (...args) {
// write to file here
// _console[methodName].apply(this, args);
// call origin method
JSServe.Connection.send_to_julia({
msg_type: "4",
message: JSON.stringify(args),
});
return
};
},
});
}
// Oh boi! This is a bit of a hack...
// But helps to debug on the CI!
window._console = console;
window.console = traceMethodCalls(console);

window.WGL = {
deserialize_scene,
threejs_module,
Expand Down

0 comments on commit 1c74e41

Please sign in to comment.