log.js
1.12 KB
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
51
52
53
54
// Requires
var chalk = require('chalk');
var config = require('./../config.json');
// Utilities
function getTime() {
var now = new Date(),
time = [now.getHours(), now.getMinutes(), now.getSeconds()];
for(var i = 0; i < 3; i++) {
if(time[i] < 10) {
time[i] = "0" + time[i];
}
}
return '[' + time.join(":") + '] ';
}
// Exports
module.exports = function(type, message) {
switch(type) {
case 'start':
type = chalk.bold.green.dim('[Start] ');
break;
case 'stop':
type = chalk.bold.red.dim('[Stop] ');
break;
case 'error':
type = chalk.bold.red.dim('[Error] ');
break;
case 'info':
type = chalk.bold.blue('[Info] ');
break;
case 'socket':
type = chalk.bold.magenta('[Socket] ');
break;
case 'pm':
type = chalk.bold.yellow.dim('[PM] ');
break;
case 'message':
type = chalk.bold.cyan.dim('[Message] ');
break;
}
console.log(getTime() + type + message);
}