Skip to content

Commit

Permalink
enhance(logger): avoid extra work for isDebug if DEBUG is not def…
Browse files Browse the repository at this point in the history
…ined
  • Loading branch information
ardatan committed Jul 17, 2023
1 parent 0160a0e commit f11e9b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-baboons-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-mesh/utils': patch
---

Avoid extra work for `isDebug` if `DEBUG` is not defined
13 changes: 8 additions & 5 deletions packages/utils/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ export class DefaultLogger implements Logger {
}

private get isDebug() {
return (
process.env.DEBUG === '1' ||
(globalThis as any).DEBUG === '1' ||
this.name.includes(process.env.DEBUG || (globalThis as any).DEBUG)
);
if (process.env.DEBUG) {
return (
process.env.DEBUG === '1' ||
(globalThis as any).DEBUG === '1' ||
this.name.includes(process.env.DEBUG || (globalThis as any).DEBUG)
);
}
return false;
}

private get prefix() {
Expand Down

0 comments on commit f11e9b3

Please sign in to comment.