Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
case 'h':
opts.host = option.optarg;
break;
case 'k':
opts.keyPath = option.optarg;
break;
case 'u':
opts.url = url.parse(option.optarg).href;
break;
case 'v':
// Allows us to set -vvv -> this little hackery
// just ensures that we're never < TRACE
LOG.level(Math.max(bunyan.TRACE, (LOG.level() - 10)));
if (LOG.level() <= bunyan.DEBUG)
LOG = LOG.child({src: true});
break;
default:
process.exit(1);
break;
}
}
if (!opts.url && !process.env.MANTA_URL)
usage('url is a required argument');
if (!opts.user && !process.env.MANTA_USER)
usage('account is a required argument');
case 'h':
opts.host = option.optarg;
break;
case 'k':
opts.keyPath = option.optarg;
break;
case 'u':
opts.url = url.parse(option.optarg).href;
break;
case 'v':
// Allows us to set -vvv -> this little hackery
// just ensures that we're never < TRACE
LOG.level(Math.max(bunyan.TRACE, (LOG.level() - 10)));
if (LOG.level() <= bunyan.DEBUG)
LOG = LOG.child({src: true});
break;
default:
process.exit(1);
break;
}
}
if (!opts.url && !process.env.MANTA_URL)
usage('url is a required argument');
if (!opts.user && !process.env.MANTA_USER)
usage('account is a required argument');
if (record.level >= bunyan.ERROR) {
global.OPBEAT_CLIENT.setExtraContext(_.assign({
level: OpbeatStream.levels[record.level],
}, _.omit(record, [ 'err', 'level', 'name', 'req', 'v' ])));
global.OPBEAT_CLIENT.captureError(record.err);
} else {
global.OPBEAT_CLIENT.setExtraContext(_.assign({
level: OpbeatStream.levels[record.level],
}, _.omit(record, [ 'level', 'name', 'v' ])));
}
}
}
OpbeatStream.levels = {
[bunyan.TRACE]: 'debug',
[bunyan.DEBUG]: 'debug',
[bunyan.INFO]: 'info',
[bunyan.WARN]: 'warning',
[bunyan.ERROR]: 'error',
[bunyan.FATAL]: 'fatal',
};
module.exports = bunyan.createLogger({
name: 'app-log',
streams: process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test' ? [
{ level: bunyan.TRACE, type: 'raw', stream: prettyStream },
] : [
{ level: bunyan.TRACE, type: 'raw', stream: new FileStream(path.join(loggerConfig.path, process.pid + '.log')) },
// { level: bunyan.TRACE, type: 'raw', stream: new OpbeatStream() },
],
serializers: _.defaults({
function parseOptions() {
var option;
var opts = {};
var parser = new getopt.BasicParser('vf:(file)', process.argv);
while ((option = parser.getopt()) !== undefined) {
switch (option.option) {
case 'f':
opts.file = option.optarg;
break;
case 'v':
// Allows us to set -vvv -> this little hackery
// just ensures that we're never < TRACE
LOG_LEVEL_OVERRIDE = true;
LOG.level(Math.max(bunyan.TRACE, (LOG.level() - 10)));
if (LOG.level() <= bunyan.DEBUG)
LOG = LOG.child({src: true});
break;
default:
LOG.fatal('Unsupported option: ', option.option);
process.abort();
break;
}
}
return (opts);
}
case 'h':
usage();
break;
case 'p':
opts.port = parseInt(option.optarg, 10);
break;
case 'u':
opts.user = option.optarg;
break;
case 'v':
// Allows us to set -vvv -> this little hackery
// just ensures that we're never < TRACE
LOG.level(Math.max(bunyan.TRACE, LOG.level() - 10));
if (LOG.level() <= bunyan.DEBUG) {
LOG = LOG.child({ src: true });
}
break;
case 'z':
opts.password = option.optarg;
break;
default:
usage('invalid option: ' + option.option);
break;
}
}
_getRosLogLevel(bunyanLogLevel) {
// ROS log levels defined in rosgraph_msgs/Log
// bunyan trace and debug levels will both map to ROS debug
if (bunyanLogLevel === bunyan.TRACE) {
return RosgraphLogMsg.Constants.DEBUG;
}
// else
return RosgraphLogMsg.Constants[bunyan.nameFromLevel[bunyanLogLevel].toUpperCase()];
}
protected toBunyanLevel(logLevel: number): number {
switch (logLevel) {
case LogLevel.FATAL:
return bunyan.FATAL;
case LogLevel.ERROR:
return bunyan.ERROR;
case LogLevel.WARN:
return bunyan.WARN;
case LogLevel.INFO:
return bunyan.INFO;
case LogLevel.DEBUG:
return bunyan.DEBUG;
case LogLevel.TRACE:
return bunyan.TRACE;
default:
return bunyan.INFO;
}
}
private mapLevelToString(level: any): any {
let response: string;
switch (level) {
case bunyan.TRACE: {
response = "Trace";
break;
}
case bunyan.DEBUG: {
response = "Debug";
break;
}
case bunyan.INFO: {
response = "Information";
break;
}
case bunyan.WARN: {
response = "Warning";
break;
}
case bunyan.ERROR: {