Skip to content

Commit

Permalink
Add missing changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Feb 14, 2025
1 parent 56b4036 commit eee582a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-pandas-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-mesh/utils': patch
---

Add changeset
20 changes: 10 additions & 10 deletions packages/legacy/utils/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class DefaultLogger implements Logger {

private get prefix() {
return this.name
? `${titleBold(this.name.toString().trim())} ` /* trailing space because prefix is directly used in logged message */
? `[${titleBold(this.name.toString().trim())}] ` /* trailing space because prefix is directly used in logged message */
: ``;
}

Expand All @@ -75,7 +75,7 @@ export class DefaultLogger implements Logger {
return noop;
}
this.console.log(
`[timestamp=${getTimestamp()}] ${this.prefix}`.trim() /* trim in case prefix is empty */,
`[${getTimestamp()}] ${this.prefix}`.trim() /* trim in case prefix is empty */,
...args,
);
}
Expand All @@ -85,7 +85,7 @@ export class DefaultLogger implements Logger {
return noop;
}
this.console.warn(
`[timestamp=${getTimestamp()}] [level=WARN] ${this.prefix}${ANSI_CODES.orange}`,
`[${getTimestamp()}] WARN ${this.prefix}${ANSI_CODES.orange}`,
...args,
ANSI_CODES.reset,
);
Expand All @@ -96,7 +96,7 @@ export class DefaultLogger implements Logger {
return noop;
}
this.console.info(
`[timestamp=${getTimestamp()}] [level=INFO] ${this.prefix}${ANSI_CODES.cyan}`,
`[${getTimestamp()}] INFO ${this.prefix}${ANSI_CODES.cyan}`,
...args,
ANSI_CODES.reset,
);
Expand All @@ -107,7 +107,7 @@ export class DefaultLogger implements Logger {
return noop;
}
this.console.error(
`[timestamp=${getTimestamp()}] [level=ERROR] ${this.prefix}${ANSI_CODES.red}`,
`[${getTimestamp()}] ERROR ${this.prefix}${ANSI_CODES.red}`,
...args,
ANSI_CODES.reset,
);
Expand All @@ -119,7 +119,7 @@ export class DefaultLogger implements Logger {
}
const flattenedArgs = handleLazyMessage(lazyArgs);
this.console.debug(
`[timestamp=${getTimestamp()}] [level=DEBUG] ${this.prefix}${ANSI_CODES.magenta}`,
`[${getTimestamp()}] DEBUG ${this.prefix}${ANSI_CODES.magenta}`,
...flattenedArgs,
ANSI_CODES.reset,
);
Expand All @@ -131,7 +131,7 @@ export class DefaultLogger implements Logger {
return this;
}
return new DefaultLogger(
this.name ? `${this.name} ${name}` : name,
this.name ? `${this.name}, ${name}` : name,
this.logLevel,
undefined,
this.console,
Expand All @@ -141,7 +141,7 @@ export class DefaultLogger implements Logger {
addPrefix(prefix: string | Record<string, string | number>): Logger {
prefix = stringifyName(prefix);
if (!this.name?.includes(prefix)) {
this.name = this.name ? `${this.name} ${prefix}` : prefix;
this.name = this.name ? `${this.name}, ${prefix}` : prefix;
}
return this;
}
Expand All @@ -153,11 +153,11 @@ export class DefaultLogger implements Logger {

function stringifyName(name: string | Record<string, string | number>) {
if (typeof name === 'string' || typeof name === 'number') {
return `[${name}]`;
return `${name}`;
}
const names: string[] = [];
for (const [key, value] of Object.entries(name)) {
names.push(`${key}=${value}`);
}
return `[${names.join(', ')}]`;
return `${names.join(', ')}`;
}

0 comments on commit eee582a

Please sign in to comment.