diff --git a/src/logging.ts b/src/logging.ts index 4b70437..e86985c 100644 --- a/src/logging.ts +++ b/src/logging.ts @@ -1,15 +1,15 @@ import {LogMethod, Logger} from './types' -export const primitiveOrJsonLogger = getLoggerTransformer(method => { +export const primitiveOrJsonLogger = getLoggerTransformer(log => { const transformed: LogMethod = (...args) => { if (args.length === 1 && Array.isArray(args[0])) { args[0].forEach(item => transformed(item)) } else if (args.every(isPrimitive)) { - method(...args) + log(...args) } else if (args.length === 1) { - method(JSON.stringify(args[0], null, 2)) + log(JSON.stringify(args[0], null, 2)) } else { - method(JSON.stringify(args, null, 2)) + log(JSON.stringify(args, null, 2)) } } diff --git a/test/e2e.test.ts b/test/e2e.test.ts index 8311207..7b12386 100644 --- a/test/e2e.test.ts +++ b/test/e2e.test.ts @@ -2,6 +2,7 @@ import {execa} from 'execa' import * as path from 'path' import stripAnsi from 'strip-ansi' import {expect, test} from 'vitest' +import '../src' // make sure vitest reruns this file after every change const tsx = async (file: string, args: string[]) => { const {all} = await execa('./node_modules/.bin/tsx', ['test/fixtures/' + file, ...args], {