diff --git a/packages/astro/src/core/add/index.ts b/packages/astro/src/core/add/index.ts index 7790a71f0..4062e59e5 100644 --- a/packages/astro/src/core/add/index.ts +++ b/packages/astro/src/core/add/index.ts @@ -539,7 +539,6 @@ async function tryToInstallIntegrations({ const installCommand = await getInstallIntegrationsCommand({ integrations, cwd }); if (installCommand === null) { - info(logging, null); return UpdateResult.none; } else { const coloredOutput = `${bold(installCommand.pm)} ${ diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index a7b902dd3..fc7aa80bb 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -168,8 +168,8 @@ export class App { }); return response; - } catch (err) { - error(this.#logging, 'ssr', err); + } catch (err: any) { + error(this.#logging, 'ssr', err.stack || err.message || String(err)); return new Response(null, { status: 500, statusText: 'Internal server error', diff --git a/packages/astro/src/core/logger/console.ts b/packages/astro/src/core/logger/console.ts index 4769381f3..dfe732bd7 100644 --- a/packages/astro/src/core/logger/console.ts +++ b/packages/astro/src/core/logger/console.ts @@ -1,5 +1,4 @@ import { bold, cyan, dim, red, reset, yellow } from 'kleur/colors'; -import { format as utilFormat } from 'util'; import type { LogMessage } from './core.js'; import { dateTimeFormat, levels } from './core.js'; @@ -33,7 +32,7 @@ export const consoleLogDestination = { return reset(prefix); } - let message = utilFormat(...event.args); + let message = event.message; // For repeat messages, only update the message counter if (message === lastMessage) { lastMessageCount++; diff --git a/packages/astro/src/core/logger/core.ts b/packages/astro/src/core/logger/core.ts index 6a4366719..debd721dd 100644 --- a/packages/astro/src/core/logger/core.ts +++ b/packages/astro/src/core/logger/core.ts @@ -32,7 +32,6 @@ export interface LogMessage { type: string | null; level: LoggerLevel; message: string; - args: Array; } export const levels: Record = { @@ -48,15 +47,14 @@ export function log( opts: LogOptions, level: LoggerLevel, type: string | null, - ...args: Array + message: string, ) { const logLevel = opts.level; const dest = opts.dest; const event: LogMessage = { type, level, - args, - message: '', + message }; // test if this level is enabled or not @@ -68,26 +66,26 @@ export function log( } /** Emit a user-facing message. Useful for UI and other console messages. */ -export function info(opts: LogOptions, type: string | null, ...messages: Array) { - return log(opts, 'info', type, ...messages); +export function info(opts: LogOptions, type: string | null, message: string) { + return log(opts, 'info', type, message); } /** Emit a warning message. Useful for high-priority messages that aren't necessarily errors. */ -export function warn(opts: LogOptions, type: string | null, ...messages: Array) { - return log(opts, 'warn', type, ...messages); +export function warn(opts: LogOptions, type: string | null, message: string) { + return log(opts, 'warn', type, message); } /** Emit a error message, Useful when Astro can't recover from some error. */ -export function error(opts: LogOptions, type: string | null, ...messages: Array) { - return log(opts, 'error', type, ...messages); +export function error(opts: LogOptions, type: string | null, message: string) { + return log(opts, 'error', type, message); } type LogFn = typeof info | typeof warn | typeof error; export function table(opts: LogOptions, columns: number[]) { return function logTable(logFn: LogFn, ...input: Array) { - const messages = columns.map((len, i) => padStr(input[i].toString(), len)); - logFn(opts, null, ...messages); + const message = columns.map((len, i) => padStr(input[i].toString(), len)).join(' '); + logFn(opts, null, message); }; } diff --git a/packages/astro/src/core/logger/node.ts b/packages/astro/src/core/logger/node.ts index 23bb2e8bc..29ce110f2 100644 --- a/packages/astro/src/core/logger/node.ts +++ b/packages/astro/src/core/logger/node.ts @@ -3,7 +3,6 @@ import { bold, cyan, dim, red, reset, yellow } from 'kleur/colors'; import * as readline from 'readline'; import { Writable } from 'stream'; import stringWidth from 'string-width'; -import { format as utilFormat } from 'util'; import { dateTimeFormat, error, info, warn } from './core.js'; type ConsoleStream = Writable & { @@ -39,7 +38,8 @@ export const nodeLogDestination = new Writable({ return reset(prefix); } - let message = utilFormat(...event.args); + // console.log({msg: event.message, args: event.args}); + let message = event.message; // For repeat messages, only update the message counter if (message === lastMessage) { lastMessageCount++; @@ -90,7 +90,6 @@ export interface LogMessage { type: string | null; level: LoggerLevel; message: string; - args: Array; } export const levels: Record = { diff --git a/packages/astro/src/core/preview/index.ts b/packages/astro/src/core/preview/index.ts index 9f141d875..7c5b92e75 100644 --- a/packages/astro/src/core/preview/index.ts +++ b/packages/astro/src/core/preview/index.ts @@ -124,7 +124,7 @@ export default async function preview( port++; return listen(); // retry } else { - error(logging, 'astro', err.stack); + error(logging, 'astro', err.stack || err.message); httpServer?.removeListener('error', onError); reject(err); // reject } diff --git a/packages/astro/test/static-build.test.js b/packages/astro/test/static-build.test.js index a8c67eff3..7e1c4c872 100644 --- a/packages/astro/test/static-build.test.js +++ b/packages/astro/test/static-build.test.js @@ -176,7 +176,7 @@ describe('Static build', () => { for (const log of logs) { if ( log.type === 'ssg' && - /[hH]eaders are not exposed in static \(SSG\) output mode/.test(log.args[0]) + /[hH]eaders are not exposed in static \(SSG\) output mode/.test(log.message) ) { found = true; }