From 597f2d8d4d9b91ee586b9787d6ba52d247e4ff87 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Sat, 14 Sep 2024 23:30:06 +0200 Subject: feat: print `Listening on` messages on stderr instead of stdout (#25491) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/denoland/deno/issues/25114 --------- Signed-off-by: Leo Kettmeir Co-authored-by: Bartek IwaƄczuk Co-authored-by: crowlkats Co-authored-by: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> --- runtime/js/99_main.js | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) (limited to 'runtime/js/99_main.js') diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index f447a9eef..aaf12a1c4 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -3,6 +3,7 @@ // Remove Intl.v8BreakIterator because it is a non-standard API. delete Intl.v8BreakIterator; +import * as internalConsole from "ext:deno_console/01_console.js"; import { core, internals, primordials } from "ext:core/mod.js"; const ops = core.ops; import { @@ -578,36 +579,19 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) { if (mode === executionModes.serve) { if (serveIsMain && serveWorkerCount) { - // deno-lint-ignore no-console - const origLog = console.log; - // deno-lint-ignore no-console - const origError = console.error; - const prefix = `[serve-worker-0 ]`; - // deno-lint-ignore no-console - console.log = (...args) => { - return origLog(prefix, ...new primordials.SafeArrayIterator(args)); - }; - // deno-lint-ignore no-console - console.error = (...args) => { - return origError(prefix, ...new primordials.SafeArrayIterator(args)); - }; + // deno-lint-ignore no-global-assign + console = new internalConsole.Console((msg, level) => + core.print("[serve-worker-0 ] " + msg, level > 1) + ); } else if (serveWorkerCount !== null) { - // deno-lint-ignore no-console - const origLog = console.log; - // deno-lint-ignore no-console - const origError = console.error; const base = `serve-worker-${serveWorkerCount + 1}`; // 15 = "serve-worker-nn".length, assuming // serveWorkerCount < 100 const prefix = `[${StringPrototypePadEnd(base, 15, " ")}]`; - // deno-lint-ignore no-console - console.log = (...args) => { - return origLog(prefix, ...new primordials.SafeArrayIterator(args)); - }; - // deno-lint-ignore no-console - console.error = (...args) => { - return origError(prefix, ...new primordials.SafeArrayIterator(args)); - }; + // deno-lint-ignore no-global-assign + console = new internalConsole.Console((msg, level) => + core.print(`${prefix} ` + msg, level > 1) + ); } } -- cgit v1.2.3