diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-06-27 02:27:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-27 02:27:50 +0200 |
commit | 7b9737b9f4c25e1d25bfb352198cf24a50ceb2de (patch) | |
tree | 4f853a8218f5d0607304db33e2b02d87976678a7 /runtime/js | |
parent | 015f252066c21bd6d36e5b4d58a34dd40e4c0db0 (diff) |
feat(inspector): pipe console messages between terminal and inspector (#11134)
This commit adds support for piping console messages to inspector.
This is done by "wrapping" Deno's console implementation with default
console provided by V8 by the means of "Deno.core.callConsole" binding.
Effectively each call to "console.*" methods calls a method on Deno's
console and V8's console.
Diffstat (limited to 'runtime/js')
-rw-r--r-- | runtime/js/99_main.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index db334caea..91d485069 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -459,6 +459,10 @@ delete Object.prototype.__proto__; if (hasBootstrapped) { throw new Error("Worker runtime already bootstrapped"); } + + const consoleFromV8 = window.console; + const wrapConsole = window.__bootstrap.console.wrapConsole; + // Remove bootstrapping data from the global scope delete globalThis.__bootstrap; delete globalThis.bootstrap; @@ -467,6 +471,10 @@ delete Object.prototype.__proto__; Object.defineProperties(globalThis, windowOrWorkerGlobalScope); Object.defineProperties(globalThis, mainRuntimeGlobalProperties); Object.setPrototypeOf(globalThis, Window.prototype); + + const consoleFromDeno = globalThis.console; + wrapConsole(consoleFromDeno, consoleFromV8); + eventTarget.setEventTargetData(globalThis); defineEventHandler(window, "load", null); @@ -539,6 +547,10 @@ delete Object.prototype.__proto__; if (hasBootstrapped) { throw new Error("Worker runtime already bootstrapped"); } + + const consoleFromV8 = window.console; + const wrapConsole = window.__bootstrap.console.wrapConsole; + // Remove bootstrapping data from the global scope delete globalThis.__bootstrap; delete globalThis.bootstrap; @@ -548,6 +560,10 @@ delete Object.prototype.__proto__; Object.defineProperties(globalThis, workerRuntimeGlobalProperties); Object.defineProperties(globalThis, { name: util.readOnly(name) }); Object.setPrototypeOf(globalThis, DedicatedWorkerGlobalScope.prototype); + + const consoleFromDeno = globalThis.console; + wrapConsole(consoleFromDeno, consoleFromV8); + eventTarget.setEventTargetData(globalThis); runtimeStart( |