/
Log.js
42 lines (33 loc) · 821 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
41
42
var color = require("ansi-color").set;
var COLORS = {
"info": "black",
"error": "red+bold",
"warn": "green",
"debug": "magenta",
"fatal": "black+yellow_bg+bold",
}
var Logger = Klass({
statics: {
logThis: function (str, type) {
var now = new Date();
//var formated_date = now.format("dddd, mmmm dS, yyyy, h:MM:ss TT");
console.log(now + " ", color(type.toUpperCase(), COLORS[type]), ": " + str);
},
info: function (str) {
this.logThis(str, 'info');
},
error: function (str) {
this.logThis(str, 'error');
},
debug: function (str) {
this.logThis(str, 'debug');
},
warn: function (str) {
this.logThis(str, 'warn');
},
fatal: function (str) {
this.logThis(str, 'fatal');
}
}
});
module.exports = Logger;