-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.js
More file actions
44 lines (37 loc) · 848 Bytes
/
logger.js
File metadata and controls
44 lines (37 loc) · 848 Bytes
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
var winston = require('winston');
var customLevels = {
levels: {
speech: 0,
data: 1,
info: 2,
warn: 3,
announce: 4
},
colors: {
speech: 'cyan',
data: 'grey',
info: 'yellow',
warn: 'red',
announce: 'green'
}
};
var logger = null;
var setup = function(){
winston.addColors(customLevels.colors);
logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)(),
new (winston.transports.File)({ filename: 'guide.log' })
],
levels: customLevels.levels
});
}
var log2 = function(type,text){
logger.log(type,text);
}
var log=function log(type,text){
txt = "["+type.toUpperCase()+"] "+text;
console.log(txt[customLevels.colors[type]]);
}
module.exports.setup = setup;
module.exports.log = log;