From ef7e7271b65e940fe49868ca306d1a053132b4e2 Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 12 Feb 2021 13:41:45 -0600 Subject: [PATCH] Fix unreadable wtfnode output --- test/wtfnode.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/wtfnode.ts b/test/wtfnode.ts index 2dfce59a9..2d31a4e66 100644 --- a/test/wtfnode.ts +++ b/test/wtfnode.ts @@ -1,7 +1,23 @@ +import * as util from "util" import * as wtfnode from "wtfnode" +// Jest seems to hijack console.log in a way that makes the output difficult to +// read. So we'll write directly to process.stderr instead. +const write = (...args: [any, ...any]) => { + if (args.length > 0) { + process.stderr.write(util.format(...args) + "\n") + } +} +wtfnode.setLogger("info", write) +wtfnode.setLogger("warn", write) +wtfnode.setLogger("error", write) + let active = false +/** + * Start logging open handles periodically. This can be used to see what is + * hanging open if anything. + */ export function setup(): void { if (active) { return