From edc933ca889af5ad7e756c06dbce36fb67a86234 Mon Sep 17 00:00:00 2001 From: Andrew Stacy Date: Tue, 17 Sep 2024 14:46:28 -0400 Subject: [PATCH] fix: fixes type issue where sealTag expected only strings as values in template literal --- src/log.ts | 2 +- test/seal.test.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/log.ts b/src/log.ts index 2e0be13..910baf4 100644 --- a/src/log.ts +++ b/src/log.ts @@ -470,7 +470,7 @@ export default class Log { cfg?: UserConfiguration ) { this._cfg = new Configuration({ ...this._cfg.exportValues(), ...cfg }); - return (strings: TemplateStringsArray, ...values: string[]) => { + return (strings: TemplateStringsArray, ...values: unknown[]) => { const message = String.raw({ raw: strings }, ...values); const sealed = SealedLog(Log, this._cfg, this.modifierData, this.modifierQueue); const _method: keyof typeof sealed = method; diff --git a/test/seal.test.ts b/test/seal.test.ts index af07e54..d3f1c44 100644 --- a/test/seal.test.ts +++ b/test/seal.test.ts @@ -49,4 +49,20 @@ describe('Configuration', () => { logger3.log('This is a log from a sealed logger.'); }); + + test('sealTag returns a template literal tag function that generates a log of the sealed level', () => { + console.error = vi.fn(); + + const logger1 = adze.withEmoji.seal(); + const ERR = logger1.sealTag('error'); + + ERR`Something went wrong with node ${1}! ${new Error('An error occurred')}`; + + expect(console.error).toHaveBeenCalledWith( + '%c🔥 %c Error', + 'font-size: 12px;', + 'padding-right: 24px; font-size: 12px; border-radius: 4px; background: linear-gradient(to right, #fff, #ffd1d1); color: #a4000f; border-color: #e3bbbb;', + 'Something went wrong with node 1! Error: An error occurred' + ); + }); });