summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
authorMarvin Hagemeister <marvin@deno.com>2024-09-14 23:30:06 +0200
committerGitHub <noreply@github.com>2024-09-14 23:30:06 +0200
commit597f2d8d4d9b91ee586b9787d6ba52d247e4ff87 (patch)
tree82bfa7272208b81b34e79572f3c9a5bcc6c4658f /runtime/js
parentaf2d992ecd2b9320072164b6ee295c31a3194406 (diff)
feat: print `Listening on` messages on stderr instead of stdout (#25491)
Fixes https://github.com/denoland/deno/issues/25114 --------- Signed-off-by: Leo Kettmeir <crowlkats@toaxl.com> Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com> Co-authored-by: crowlkats <crowlkats@toaxl.com> Co-authored-by: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com>
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/99_main.js34
1 files changed, 9 insertions, 25 deletions
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)
+ );
}
}