Skip to content

Commit

Permalink
fix: fixes type issue where sealTag expected only strings as values i…
Browse files Browse the repository at this point in the history
…n template literal
  • Loading branch information
Andrew Stacy committed Sep 17, 2024
1 parent 0642293 commit edc933c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ export default class Log<N extends string = string, Msg = unknown> {
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<N, Msg>, this._cfg, this.modifierData, this.modifierQueue);
const _method: keyof typeof sealed = method;
Expand Down
16 changes: 16 additions & 0 deletions test/seal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
});
});

0 comments on commit edc933c

Please sign in to comment.