mirror of
https://github.com/Hopiu/webapi-eca.git
synced 2026-05-04 21:44:45 +00:00
66 lines
1.6 KiB
JavaScript
66 lines
1.6 KiB
JavaScript
// Generated by CoffeeScript 1.6.3
|
|
(function() {
|
|
var bunyan, exports, path,
|
|
_this = this;
|
|
|
|
path = require('path');
|
|
|
|
bunyan = require('bunyan');
|
|
|
|
/*
|
|
Module call
|
|
-----------
|
|
|
|
Calling the module as a function will act as a constructor and load the config file.
|
|
It is possible to hand an args object with the properties nolog (true if no outputs shall
|
|
be generated) and configPath for a custom configuration file path.
|
|
|
|
@param {Object} args
|
|
*/
|
|
|
|
|
|
exports = module.exports = function(args) {
|
|
var e, emptylog, opt;
|
|
emptylog = {
|
|
info: function() {},
|
|
warn: function() {},
|
|
error: function() {}
|
|
};
|
|
args = args != null ? args : {};
|
|
if (args.nolog) {
|
|
return emptylog;
|
|
} else {
|
|
try {
|
|
opt = {
|
|
name: "webapi-eca"
|
|
};
|
|
if (args['mode'] === 'development') {
|
|
opt.src = true;
|
|
}
|
|
if (args['file-path']) {
|
|
_this.logPath = path.resolve(__dirname, '..', 'logs', args['file-path']);
|
|
} else {
|
|
_this.logPath = path.resolve(__dirname, '..', 'logs', 'server.log');
|
|
}
|
|
opt.streams = [
|
|
{
|
|
level: args['io-level'],
|
|
stream: process.stdout
|
|
}, {
|
|
level: args['file-level'],
|
|
type: 'rotating-file',
|
|
path: _this.logPath,
|
|
period: '1d',
|
|
count: 3
|
|
}
|
|
];
|
|
return bunyan.createLogger(opt);
|
|
} catch (_error) {
|
|
e = _error;
|
|
console.error(e);
|
|
return emptylog;
|
|
}
|
|
}
|
|
};
|
|
|
|
}).call(this);
|