0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-01 12:16:11 -05:00

fix(ext/node): fix formatting of debug logs (#27772)

This commit is contained in:
Yoshiya Hinosawa 2025-01-22 20:13:13 +09:00 committed by GitHub
parent c930e13ff1
commit 773825aeb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 35 additions and 38 deletions

View file

@ -4,8 +4,6 @@
// TODO(petamoriken): enable prefer-primordials for node polyfills // TODO(petamoriken): enable prefer-primordials for node polyfills
// deno-lint-ignore-file prefer-primordials // deno-lint-ignore-file prefer-primordials
import { inspect } from "ext:deno_node/internal/util/inspect.mjs";
// `debugImpls` and `testEnabled` are deliberately not initialized so any call // `debugImpls` and `testEnabled` are deliberately not initialized so any call
// to `debuglog()` before `initializeDebugEnv()` is called will throw. // to `debuglog()` before `initializeDebugEnv()` is called will throw.
let debugImpls: Record<string, (...args: unknown[]) => void>; let debugImpls: Record<string, (...args: unknown[]) => void>;
@ -49,10 +47,9 @@ function debuglogImpl(
if (debugImpls[set] === undefined) { if (debugImpls[set] === undefined) {
if (enabled) { if (enabled) {
emitWarningIfNeeded(set); emitWarningIfNeeded(set);
debugImpls[set] = function debug(...args: unknown[]) { debugImpls[set] = function debug(msg, ...args: unknown[]) {
const msg = args.map((arg) => inspect(arg)).join(" ");
// deno-lint-ignore no-console // deno-lint-ignore no-console
console.error("%s %s: %s", set, String(Deno.pid), msg); console.error("%s %s: " + msg, set, String(Deno.pid), ...args);
}; };
} else { } else {
debugImpls[set] = noop; debugImpls[set] = noop;

View file

@ -1,36 +1,36 @@
STREAM [WILDCARD] 'resume' STREAM [WILDCARD]: resume
STREAM [WILDCARD] 'resume' false STREAM [WILDCARD]: resume false
STREAM [WILDCARD] 'read' 0 STREAM [WILDCARD]: read 0
STREAM [WILDCARD] 'need readable' false STREAM [WILDCARD]: need readable false
STREAM [WILDCARD] 'length less than watermark' true STREAM [WILDCARD]: length less than watermark true
STREAM [WILDCARD] 'reading, ended or constructing' false STREAM [WILDCARD]: reading, ended or constructing false
STREAM [WILDCARD] 'flow' true STREAM [WILDCARD]: flow true
STREAM [WILDCARD] 'read' undefined STREAM [WILDCARD]: read undefined
STREAM [WILDCARD] 'need readable' true STREAM [WILDCARD]: need readable true
STREAM [WILDCARD] 'length less than watermark' true STREAM [WILDCARD]: length less than watermark true
STREAM [WILDCARD] 'reading, ended or constructing' false STREAM [WILDCARD]: reading, ended or constructing false
STREAM [WILDCARD] 'read' 0 STREAM [WILDCARD]: read 0
STREAM [WILDCARD] 'need readable' true STREAM [WILDCARD]: need readable true
STREAM [WILDCARD] 'length less than watermark' true STREAM [WILDCARD]: length less than watermark true
STREAM [WILDCARD] 'reading, ended or constructing' false STREAM [WILDCARD]: reading, ended or constructing false
STREAM [WILDCARD] 'maybeReadMore read 0' STREAM [WILDCARD]: maybeReadMore read 0
STREAM [WILDCARD] 'read' 0 STREAM [WILDCARD]: read 0
STREAM [WILDCARD] 'need readable' true STREAM [WILDCARD]: need readable true
STREAM [WILDCARD] 'length less than watermark' true STREAM [WILDCARD]: length less than watermark true
STREAM [WILDCARD] 'do read' STREAM [WILDCARD]: do read
STREAM [WILDCARD] 'readableAddChunk' <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64 0a> STREAM [WILDCARD]: readableAddChunk <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64 0a>
hello world hello world
STREAM [WILDCARD] 'maybeReadMore read 0' STREAM [WILDCARD]: maybeReadMore read 0
STREAM [WILDCARD] 'read' 0 STREAM [WILDCARD]: read 0
STREAM [WILDCARD] 'need readable' true STREAM [WILDCARD]: need readable true
STREAM [WILDCARD] 'length less than watermark' true STREAM [WILDCARD]: length less than watermark true
STREAM [WILDCARD] 'do read' STREAM [WILDCARD]: do read
STREAM [WILDCARD] 'readableAddChunk' null STREAM [WILDCARD]: readableAddChunk null
STREAM [WILDCARD] 'onEofChunk' STREAM [WILDCARD]: onEofChunk
STREAM [WILDCARD] 'emitReadable_' false 0 true STREAM [WILDCARD]: emitReadable_ false 0 true
STREAM [WILDCARD] 'flow' true STREAM [WILDCARD]: flow true
STREAM [WILDCARD] 'read' undefined STREAM [WILDCARD]: read undefined
STREAM [WILDCARD] 'endReadable' false STREAM [WILDCARD]: endReadable false
STREAM [WILDCARD] 'endReadableNT' false 0 STREAM [WILDCARD]: endReadableNT false 0
Finished reading the file Finished reading the file