-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add disable log option
log
. (#183)
- Loading branch information
1 parent
c05707f
commit 51fd8c5
Showing
5 changed files
with
55 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export class Log { | ||
_disabled?:boolean; | ||
constructor(disabled?: boolean) { | ||
this.disabled = disabled || false | ||
} | ||
get disabled () { | ||
return this._disabled; | ||
} | ||
set disabled(val: boolean) { | ||
this._disabled = val; | ||
} | ||
log = (message?: any, ...optionalParams: any[]) => { | ||
if (this.disabled) return () => {} | ||
return console.log(message, ...optionalParams) | ||
} | ||
error = (message?: any, ...optionalParams: any[]) => { | ||
if (this.disabled) return () => {} | ||
return console.error(message, ...optionalParams) | ||
} | ||
} | ||
|
||
export const log = new Log(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters