forked from yanlele/node-index
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
50 lines (49 loc) · 993 Bytes
/
index.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
45
46
47
48
49
50
'use strict';
/**
* 输出控制台日志记录
*/
const chalk = require('chalk');
const logTypeList = [
{
'type': 'info',
'color': 'gray',
'icon': '>'
},
{
'type': 'error',
'color': 'red',
'icon': '✗'
},
{
'type': 'success',
'color': 'green',
'icon': '✔'
},
{
'type': 'trace',
'color': 'dim',
'icon': '*'
},
{
'type': 'debug',
'color': 'bgBlack',
'icon': '*'
},
{
'type': 'warn',
'color': 'yellow',
'icon': '!'
},
{
'type': 'fatal',
'color': 'bgRed',
'icon': '✗'
}
];
logTypeList.forEach(function(logType) {
exports[logType.type] = function() {
let args = Array.prototype.slice.call(arguments, 0);
if(logType.icon) args = [logType.icon].concat(args);
global.console.log(chalk[logType.color].apply(global.console, args));
};
});