Skip to content

Commit

Permalink
fix: fixes condition causing warning messages any time a log doesn't …
Browse files Browse the repository at this point in the history
…print
  • Loading branch information
Andrew Stacy committed Sep 11, 2024
1 parent 1b911c2 commit 7d11815
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"prebuild": "npm run clean",
"build": "tsc --project tsconfig.prod.json && tsc-alias && rm -f ./dist/demo_funcs.js && rm -f ./dist/demo_funcs.d.ts",
"build:demo": "tsc --project tsconfig.json && tsc-alias",
"build:demo": "tsc --project tsconfig.prod.json && tsc-alias",
"clean": "rm -rf ./dist",
"docs:build": "vuepress build docs",
"docs:clean-dev": "vuepress dev docs --clean-cache",
Expand Down
18 changes: 8 additions & 10 deletions src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1257,17 +1257,15 @@ export default class Log<N extends string = string, Msg = unknown> {
public print(data: LogData): void {
// Skip printing if the Adze environment is set to test.
if (isTestEnvironment()) return;
if (data.message.length > 0) {
// Don't print if it is configured to be silent.
if (data.silent) return;
// Only print the message with arguments if it is using a method that allows arguments.
if (isMethodWithArgs(data.method)) {
console[data.method](...data.message);
} else {
console[data.method]();
}
// Don't print if it is configured to be silent.
if (data.silent) return;
// If no message, skip.
if (data.message.length < 1) return;
// Only print the message with arguments if it is using a method that allows arguments.
if (isMethodWithArgs(data.method)) {
console[data.method](...data.message);
} else {
console.warn(new Error('Adze: Cannot print a log that has never been previously printed.'));
console[data.method]();
}
}

Expand Down

0 comments on commit 7d11815

Please sign in to comment.