From 0c497d9cb63bd4a6bb8e01c0e3b843890a239d23 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Sat, 26 Oct 2024 10:53:57 +0200 Subject: [PATCH] feat: allow custom `console` in `createLogger` (#18379) --- packages/vite/src/node/logger.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/logger.ts b/packages/vite/src/node/logger.ts index a9491c477f054a..8bfa027c61fcd2 100644 --- a/packages/vite/src/node/logger.ts +++ b/packages/vite/src/node/logger.ts @@ -50,6 +50,7 @@ export interface LoggerOptions { prefix?: string allowClearScreen?: boolean customLogger?: Logger + console?: Console } // Only initialize the timeFormatter when the timestamp option is used, and @@ -73,7 +74,11 @@ export function createLogger( } const loggedErrors = new WeakSet() - const { prefix = '[vite]', allowClearScreen = true } = options + const { + prefix = '[vite]', + allowClearScreen = true, + console = globalThis.console, + } = options const thresh = LogLevels[level] const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI