forked from RonRadtke/react-native-blob-util
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathlog.js
40 lines (30 loc) · 760 Bytes
/
log.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
export default class Log {
_name:string;
_isEnable:boolean = true
_level:number = 0
constructor(name:string) {
this._name = name;
}
level(val:number) {
this._isEnable = true;
this._level = val;
}
enable() {
this._isEnable = true;
}
disable() {
this._isEnable = false;
}
verbose(...args) {
this._isEnable && this._level > 2 && console.log(this._name, 'verbose:', ...args);
}
debug(...args) {
this._isEnable && this._level > 1 && console.log(this._name, 'debug:', ...args);
}
info(...args) {
this._isEnable && this._level > 0 && console.log(this._name, 'info:', ...args);
}
error(...args) {
this._isEnable && this._level > -1 && console.warn(this._name, 'error:', ...args);
}
}