diff --git a/src/logger.ts b/src/logger.ts index fad3082..f5494ed 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -173,13 +173,7 @@ export class Logger { return } - if (values.length) { - ;(this.pino[level] as any)(mergingObject, message, ...values) - } else if (message) { - ;(this.pino[level] as any)(mergingObject, message) - } else { - ;(this.pino[level] as any)(mergingObject) - } + ;(this.pino[level] as any)(mergingObject, message, ...values) } /** diff --git a/tests/logger.spec.ts b/tests/logger.spec.ts index da9c72e..37b3e66 100644 --- a/tests/logger.spec.ts +++ b/tests/logger.spec.ts @@ -69,7 +69,7 @@ test.group('Logger', () => { ) }) - test('handle sprintf subsitutes', ({ assert }) => { + test('handle sprintf substitutes', ({ assert }) => { const messages: string[] = [] const logger = new Logger({ @@ -86,6 +86,7 @@ test.group('Logger', () => { logger.info('hello %s', 'info') logger.info('hello %s %o', 'info', { url: '/' }) logger.info('hello %s %j', 'info', { url: '/' }) + logger.info('total: %d', 0) assert.deepEqual( messages.map((m) => { @@ -105,6 +106,10 @@ test.group('Logger', () => { level: 30, msg: `hello info ${JSON.stringify({ url: '/' })}`, }, + { + level: 30, + msg: 'total: 0', + }, ] ) }) @@ -326,8 +331,8 @@ test.group('Logger', () => { assert.deepEqual(logger.bindings(), {}) assert.isFalse(logger.isLevelEnabled('info')) - assert.snapshot(logger.pinoVersion).matchInline('"8.17.2"') - assert.snapshot(logger.version).matchInline('"8.17.2"') + assert.match(logger.pinoVersion, /\d+\.\d+\.\d+/) + assert.strictEqual(logger.pinoVersion, logger.version) assert.deepEqual(logger.levels, { labels: {