-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathutils.js
executable file
·39 lines (34 loc) · 1.02 KB
/
utils.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
var winston = require('winston');
var logLevel = 5;
exports.initLog = function(name, logLevel_) {
winston.add(winston.transports.File, { filename: name, maxsize: 5000000, maxFiles: 10, level: 'debug'});
winston.remove(winston.transports.Console);
logLevel = logLevel_;
}
exports.logInfo = function(log) {
if(logLevel >= 4) {
var current = new Date();
winston.info(current + ' PID:' + process.pid + ' ' + log);
}
}
exports.logDebug = function(log) {
if(logLevel >=5) {
var current = new Date();
winston.debug(current + ' PID:' + process.pid + ' ' + log);
}
}
exports.logWarn = function(log) {
if(logLevel >= 3) {
var current = new Date();
winston.warn(current + ' PId:' + process.pid + ' ' + log);
}
}
exports.logError = function(log) {
if(logLevel >= 2) {
var current = new Date();
winston.error(current + ' PID:' + process.pid + ' ' + log);
}
}
exports.is_forever_retry_service = function(config, serviceName) {
return config.forever_retry_services.indexOf(serviceName) != -1;
}