forked from OstlerDev/PopcornTV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.js
executable file
·45 lines (41 loc) · 1.24 KB
/
logger.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
43
44
45
var Winston = require('winston');
if (process.argv[2] != undefined){
var level = process.argv[2];
} else {
var level = "Web";
}
var logger = startLogger(level);
function startLogger(LoggingLevel){
var logglyLevel = 'notice';
if (LoggingLevel == 'Debug')
logglyLevel = 'Debug';
var logger = new (Winston.Logger)({
exitOnError: false,
levels: {Debug: 0, Web: 1, DNS: 1, Streamer: 1, notice: 2, warning: 3, error: 4},
transports: [
new Winston.transports.Console({
level: LoggingLevel,
colorize: true,
prettyPrint: true,
json: false,
handleExceptions: true
}),
new (Winston.transports.File)({
filename: __dirname + '/PopcornTV.log',
level: LoggingLevel,
prettyPrint: true,
json: false,
maxsize: 10 * 1024 * 1024,
maxFiles: 3,
tailable: true,
handleExceptions: true
})
],
colors: {Debug: "red", Web: "cyan", DNS: "cyan", Streamer: "cyan", notice: "white", warning: "yellow", error: "red"}
});
if (LoggingLevel != "Web"){
logger.notice("Started logger in " + LoggingLevel + " mode!");
}
return logger;
}
module.exports=logger;