-
Notifications
You must be signed in to change notification settings - Fork 24
/
log.js
35 lines (31 loc) · 1.06 KB
/
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
var winston = require("winston")
, transports = []
;
var logger;
module.exports = function(config) {
if (!logger) {
// logging
if (config.logToConsole) {
transports.push(
new (winston.transports.Console)({
handleExceptions: true
, colorize: true
, maxsize: 200000000
, humanReadableUnhandledException: true
})
);
}
if (config.logToFile) {
transports.push(
new (winston.transports.File)({
filename: config.logToFile
, handleExceptions: true
, timestamp: true
, humanReadableUnhandledException: true
})
);
}
logger = new (winston.Logger)({ transports: transports });
}
return logger;
};