You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
687 B
25 lines
687 B
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.logger) this.logger(message); |
|
if (this.disabled) return () => {} |
|
return console.log(message, ...optionalParams) |
|
} |
|
error = (message?: any, ...optionalParams: any[]) => { |
|
if (this.logger) this.logger(message); |
|
if (this.disabled) return () => {} |
|
return console.error(message, ...optionalParams) |
|
} |
|
logger = (message?: string) => {} |
|
} |
|
|
|
export const log = new Log(); |