more 'make check' jsstyle fixes
This commit is contained in:
parent
c9f05b6743
commit
7a6c3f5ce6
11 changed files with 78 additions and 73 deletions
33
bin/bunyan
33
bin/bunyan
|
@ -20,8 +20,8 @@ var child_process = require('child_process'),
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
|
||||||
var nodeSpawnSupportsStdio = (
|
var nodeSpawnSupportsStdio = (
|
||||||
Number(process.version.split('.')[0]) >= 0
|
Number(process.version.split('.')[0]) >= 0 ||
|
||||||
|| Number(process.version.split('.')[1]) >= 8);
|
Number(process.version.split('.')[1]) >= 8);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,6 +103,7 @@ function getVersion() {
|
||||||
|
|
||||||
var format = util.format;
|
var format = util.format;
|
||||||
if (!format) {
|
if (!format) {
|
||||||
|
/* BEGIN JSSTYLED */
|
||||||
// If not node 0.6, then use its `util.format`:
|
// If not node 0.6, then use its `util.format`:
|
||||||
// <https://github.com/joyent/node/blob/master/lib/util.js#L22>:
|
// <https://github.com/joyent/node/blob/master/lib/util.js#L22>:
|
||||||
var inspect = util.inspect;
|
var inspect = util.inspect;
|
||||||
|
@ -140,6 +141,7 @@ if (!format) {
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
};
|
};
|
||||||
|
/* END JSSTYLED */
|
||||||
}
|
}
|
||||||
|
|
||||||
function indent(s) {
|
function indent(s) {
|
||||||
|
@ -438,7 +440,7 @@ function parseArgv(argv) {
|
||||||
}
|
}
|
||||||
parsed.outputMode = OM_FROM_NAME[name];
|
parsed.outputMode = OM_FROM_NAME[name];
|
||||||
if (parsed.outputMode === undefined) {
|
if (parsed.outputMode === undefined) {
|
||||||
throw new Error('unknown output mode: \''+name+"'");
|
throw new Error('unknown output mode: "'+name+'"');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '-j': // output with JSON.stringify
|
case '-j': // output with JSON.stringify
|
||||||
|
@ -1186,6 +1188,7 @@ function processFile(file, opts, stylize, callback) {
|
||||||
/**
|
/**
|
||||||
* From node async module.
|
* From node async module.
|
||||||
*/
|
*/
|
||||||
|
/* BEGIN JSSTYLED */
|
||||||
function asyncForEach(arr, iterator, callback) {
|
function asyncForEach(arr, iterator, callback) {
|
||||||
callback = callback || function () {};
|
callback = callback || function () {};
|
||||||
if (!arr.length) {
|
if (!arr.length) {
|
||||||
|
@ -1207,6 +1210,7 @@ function asyncForEach(arr, iterator, callback) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
/* END JSSTYLED */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1316,7 +1320,7 @@ function main(argv) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (opts.pid && opts.args.length > 0) {
|
if (opts.pid && opts.args.length > 0) {
|
||||||
warn("bunyan: error: can't use both '-p PID' (%s) and file (%s) args",
|
warn('bunyan: error: can\'t use both "-p PID" (%s) and file (%s) args',
|
||||||
opts.pid, opts.args.join(' '));
|
opts.pid, opts.args.join(' '));
|
||||||
return drainStdoutAndExit(1);
|
return drainStdoutAndExit(1);
|
||||||
}
|
}
|
||||||
|
@ -1334,18 +1338,19 @@ function main(argv) {
|
||||||
// Pager.
|
// Pager.
|
||||||
var nodeVer = process.versions.node.split('.').map(Number);
|
var nodeVer = process.versions.node.split('.').map(Number);
|
||||||
var paginate = (
|
var paginate = (
|
||||||
process.stdout.isTTY
|
process.stdout.isTTY &&
|
||||||
&& process.stdin.isTTY
|
process.stdin.isTTY &&
|
||||||
&& !opts.pids // Don't page if following process output.
|
!opts.pids && // Don't page if following process output.
|
||||||
&& opts.args.length > 0 // Don't page if no file args to process.
|
opts.args.length > 0 && // Don't page if no file args to process.
|
||||||
&& process.platform !== 'win32'
|
process.platform !== 'win32' &&
|
||||||
&& nodeVer >= [0,8,0]
|
nodeVer >= [0, 8, 0] &&
|
||||||
&& (opts.paginate === true
|
(opts.paginate === true ||
|
||||||
|| (opts.paginate !== false
|
(opts.paginate !== false &&
|
||||||
&& (!process.env.BUNYAN_NO_PAGER
|
(!process.env.BUNYAN_NO_PAGER ||
|
||||||
|| process.env.BUNYAN_NO_PAGER.length === 0))));
|
process.env.BUNYAN_NO_PAGER.length === 0))));
|
||||||
if (paginate) {
|
if (paginate) {
|
||||||
var pagerCmd = process.env.PAGER || 'less';
|
var pagerCmd = process.env.PAGER || 'less';
|
||||||
|
/* JSSTYLED */
|
||||||
assert.ok(pagerCmd.indexOf('"') === -1 && pagerCmd.indexOf("'") === -1,
|
assert.ok(pagerCmd.indexOf('"') === -1 && pagerCmd.indexOf("'") === -1,
|
||||||
'cannot parse PAGER quotes yet');
|
'cannot parse PAGER quotes yet');
|
||||||
var argv = pagerCmd.split(/\s+/g);
|
var argv = pagerCmd.split(/\s+/g);
|
||||||
|
|
|
@ -50,7 +50,7 @@ function logOne() {
|
||||||
var msg = [randchoice(words), randchoice(words)].join(' ');
|
var msg = [randchoice(words), randchoice(words)].join(' ');
|
||||||
var delay = randint(300);
|
var delay = randint(300);
|
||||||
//console.warn('long-running about to log.%s(..., "%s")', level, msg)
|
//console.warn('long-running about to log.%s(..., "%s")', level, msg)
|
||||||
log[level]({"word": randchoice(words), "delay": delay}, msg);
|
log[level]({'word': randchoice(words), 'delay': delay}, msg);
|
||||||
timeout = setTimeout(logOne, delay);
|
timeout = setTimeout(logOne, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -638,8 +638,9 @@ Logger.prototype._applySerializers = function (fields, excludeFields) {
|
||||||
// Check each serializer against these (presuming number of serializers
|
// Check each serializer against these (presuming number of serializers
|
||||||
// is typically less than number of fields).
|
// is typically less than number of fields).
|
||||||
Object.keys(this.serializers).forEach(function (name) {
|
Object.keys(this.serializers).forEach(function (name) {
|
||||||
if (fields[name] === undefined
|
if (fields[name] === undefined ||
|
||||||
|| (excludeFields && excludeFields[name])) {
|
(excludeFields && excludeFields[name]))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
xxx('_applySerializers; apply to "%s" key', name)
|
xxx('_applySerializers; apply to "%s" key', name)
|
||||||
|
@ -900,7 +901,7 @@ var errSerializer = Logger.stdSerializers.err = function err(err) {
|
||||||
function safeCycles() {
|
function safeCycles() {
|
||||||
var seen = [];
|
var seen = [];
|
||||||
return function (key, val) {
|
return function (key, val) {
|
||||||
if (!val || typeof val !== 'object') {
|
if (!val || typeof (val) !== 'object') {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
if (seen.indexOf(val) !== -1) {
|
if (seen.indexOf(val) !== -1) {
|
||||||
|
|
|
@ -48,10 +48,10 @@ test('log.info(BUFFER)', function (t) {
|
||||||
var rec = catcher.records[catcher.records.length - 1];
|
var rec = catcher.records[catcher.records.length - 1];
|
||||||
t.equal(rec.msg, inspect(b),
|
t.equal(rec.msg, inspect(b),
|
||||||
format('log.%s msg is inspect(BUFFER)', lvl));
|
format('log.%s msg is inspect(BUFFER)', lvl));
|
||||||
t.ok(rec["0"] === undefined,
|
t.ok(rec['0'] === undefined,
|
||||||
'no "0" array index key in record: ' + inspect(rec["0"]));
|
'no "0" array index key in record: ' + inspect(rec['0']));
|
||||||
t.ok(rec["parent"] === undefined,
|
t.ok(rec['parent'] === undefined,
|
||||||
'no "parent" array index key in record: ' + inspect(rec["parent"]));
|
'no "parent" array index key in record: ' + inspect(rec['parent']));
|
||||||
|
|
||||||
log[lvl].call(log, b, 'bar');
|
log[lvl].call(log, b, 'bar');
|
||||||
var rec = catcher.records[catcher.records.length - 1];
|
var rec = catcher.records[catcher.records.length - 1];
|
||||||
|
|
|
@ -31,27 +31,27 @@ outstr.end = function (c) {
|
||||||
var expect =
|
var expect =
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "blammo",
|
'name': 'blammo',
|
||||||
"level": 30,
|
'level': 30,
|
||||||
"msg": "bango { bang: 'boom', KABOOM: [Circular] }",
|
'msg': 'bango { bang: \'boom\', KABOOM: [Circular] }',
|
||||||
"v": 0
|
'v': 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "blammo",
|
'name': 'blammo',
|
||||||
"level": 30,
|
'level': 30,
|
||||||
"msg": "kaboom { bang: 'boom', KABOOM: [Circular] }",
|
'msg': 'kaboom { bang: \'boom\', KABOOM: [Circular] }',
|
||||||
"v": 0
|
'v': 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "blammo",
|
'name': 'blammo',
|
||||||
"level": 30,
|
'level': 30,
|
||||||
"bang": "boom",
|
'bang': 'boom',
|
||||||
"KABOOM": {
|
'KABOOM': {
|
||||||
"bang": "boom",
|
'bang': 'boom',
|
||||||
"KABOOM": "[Circular]"
|
'KABOOM': '[Circular]'
|
||||||
},
|
},
|
||||||
"msg": "",
|
'msg': '',
|
||||||
"v": 0
|
'v': 0
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -47,15 +47,15 @@ test('basic dtrace', function (t) {
|
||||||
'bunyan$target:::log-*{printf("%s", copyinstr(arg0))}',
|
'bunyan$target:::log-*{printf("%s", copyinstr(arg0))}',
|
||||||
'-c', format('node %s/log-some.js', __dirname)];
|
'-c', format('node %s/log-some.js', __dirname)];
|
||||||
var dtrace = spawn(argv[0], argv.slice(1));
|
var dtrace = spawn(argv[0], argv.slice(1));
|
||||||
//console.error("ARGV: %j", argv);
|
//console.error('ARGV: %j', argv);
|
||||||
|
|
||||||
var traces = [];
|
var traces = [];
|
||||||
dtrace.stdout.on('data', function (data) {
|
dtrace.stdout.on('data', function (data) {
|
||||||
//console.error("DTRACE STDOUT:", data.toString());
|
//console.error('DTRACE STDOUT:', data.toString());
|
||||||
traces.push(data.toString());
|
traces.push(data.toString());
|
||||||
});
|
});
|
||||||
dtrace.stderr.on('data', function (data) {
|
dtrace.stderr.on('data', function (data) {
|
||||||
console.error("DTRACE STDERR:", data.toString());
|
console.error('DTRACE STDERR:', data.toString());
|
||||||
});
|
});
|
||||||
dtrace.on('exit', function (code) {
|
dtrace.on('exit', function (code) {
|
||||||
t.notOk(code, 'dtrace exited cleanly');
|
t.notOk(code, 'dtrace exited cleanly');
|
||||||
|
|
|
@ -10,4 +10,3 @@ var log = bunyan.createLogger({
|
||||||
});
|
});
|
||||||
log.debug({foo: 'bar'}, 'hi at debug')
|
log.debug({foo: 'bar'}, 'hi at debug')
|
||||||
log.trace('hi at trace')
|
log.trace('hi at trace')
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ test('req serializer', function (t) {
|
||||||
{'foo':'bar'}
|
{'foo':'bar'}
|
||||||
];
|
];
|
||||||
for (var i = 0; i < bogusReqs.length; i++) {
|
for (var i = 0; i < bogusReqs.length; i++) {
|
||||||
log.info({req: bogusReqs[i]}, "hi");
|
log.info({req: bogusReqs[i]}, 'hi');
|
||||||
t.equal(records[i].req, bogusReqs[i]);
|
t.equal(records[i].req, bogusReqs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ test('res serializer', function (t) {
|
||||||
{'foo':'bar'}
|
{'foo':'bar'}
|
||||||
];
|
];
|
||||||
for (var i = 0; i < bogusRess.length; i++) {
|
for (var i = 0; i < bogusRess.length; i++) {
|
||||||
log.info({res: bogusRess[i]}, "hi");
|
log.info({res: bogusRess[i]}, 'hi');
|
||||||
t.equal(records[i].res, bogusRess[i]);
|
t.equal(records[i].res, bogusRess[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ test('err serializer', function (t) {
|
||||||
{'foo':'bar'}
|
{'foo':'bar'}
|
||||||
];
|
];
|
||||||
for (var i = 0; i < bogusErrs.length; i++) {
|
for (var i = 0; i < bogusErrs.length; i++) {
|
||||||
log.info({err: bogusErrs[i]}, "hi");
|
log.info({err: bogusErrs[i]}, 'hi');
|
||||||
t.equal(records[i].err, bogusErrs[i]);
|
t.equal(records[i].err, bogusErrs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue