-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdk_log.js
45 lines (34 loc) · 855 Bytes
/
sdk_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
41
42
43
44
/*
* sdk的log模块
*
* create by zengxx on 2018-11-22
*/
let config = require('./sdk_config');
let log = {};
let adapter = function (name, func) {
let _name = name;
return function () {
if (!config.baseInfo.debug) {
return ;
}
let info = 'sdk.' + _name + ' ===> ';
for (let i=0, len = arguments.length; i<len;i++) {
if (arguments[i] === undefined) {
info += "undefined" + ' ';
} else {
info += arguments[i].toString() + ' ';
}
}
func(info);
};
};
log.LOGD = adapter('LOGD', function (info) {
console.log(info);
});
log.LOGW = adapter('LOGW', function (info) {
console.warn(info);
});
log.LOGE = adapter('LOGE', function (info) {
console.error(info);
});
module.exports = log;