1 | const chalk = require('chalk');
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | const logger = {};
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | logger.debug = function (type,msg) {
|
18 | var time=__getCurrentTime();
|
19 |
|
20 | var output=['[',time,' ','debug',']',chalk.blue(type),':',msg].join('');
|
21 | console.log(output);
|
22 | }
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | logger.info = function (type,msg) {
|
30 | var time=__getCurrentTime();
|
31 |
|
32 | var output=['[',time,' ',chalk.green('info'),']',chalk.blue(type),':',chalk.green(msg)].join('');
|
33 | console.log(output);
|
34 | }
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | logger.warning = function (type,msg) {
|
42 | var time=__getCurrentTime();
|
43 |
|
44 | var output=['[',time,' ',chalk.yellow('warning'),']',chalk.blue(type),':',chalk.yellow(msg)].join('');
|
45 | console.log(output);
|
46 | }
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | logger.err = function (type,msg) {
|
54 | var time=__getCurrentTime();
|
55 |
|
56 | var output=['[',time,' ',chalk.red('err'),']',chalk.blue(type),':',chalk.red(msg)].join('');
|
57 | console.log(output);
|
58 | }
|
59 |
|
60 | function __getCurrentTime(){
|
61 | return new Date().toLocaleTimeString();
|
62 | }
|
63 |
|
64 | module.exports=logger; |
\ | No newline at end of file |