'make check' fixes

This commit is contained in:
Trent Mick 2012-06-20 16:27:41 -07:00
parent c5ba5c0147
commit 49e3c57030
2 changed files with 14 additions and 12 deletions

View file

@ -11,7 +11,7 @@ var Logger = require('../lib/bunyan');
*/ */
function MyRawStream() {} function MyRawStream() {}
MyRawStream.prototype.write = function (rec) { MyRawStream.prototype.write = function (rec) {
if (typeof(rec) !== 'object') { if (typeof (rec) !== 'object') {
console.error('error: raw stream got a non-object record: %j', rec) console.error('error: raw stream got a non-object record: %j', rec)
} else { } else {
rec.yo = 'yo'; rec.yo = 'yo';
@ -25,7 +25,7 @@ var log = new Logger({
name: 'raw-example', name: 'raw-example',
streams: [ streams: [
{ {
level: "info", level: 'info',
stream: new MyRawStream(), stream: new MyRawStream(),
raw: true raw: true
}, },

View file

@ -23,16 +23,18 @@ test('raw stream', function (t) {
var log = new Logger({ var log = new Logger({
name: 'raw-stream-test', name: 'raw-stream-test',
streams: [{ streams: [
stream: new CapturingStream(recs), {
raw: true stream: new CapturingStream(recs),
}] raw: true
}
]
}); });
log.info('first'); log.info('first');
log.info({two: 'deux'}, 'second'); log.info({two: 'deux'}, 'second');
t.equal(recs.length, 2); t.equal(recs.length, 2);
t.equal(typeof(recs[0]), 'object', 'first rec is an object'); t.equal(typeof (recs[0]), 'object', 'first rec is an object');
t.equal(recs[1].two, 'deux', '"two" field made it through'); t.equal(recs[1].two, 'deux', '"two" field made it through');
t.end(); t.end();
}); });
@ -50,7 +52,7 @@ test('raw stream (short constructor)', function (t) {
log.info({two: 'deux'}, 'second'); log.info({two: 'deux'}, 'second');
t.equal(recs.length, 2); t.equal(recs.length, 2);
t.equal(typeof(recs[0]), 'object', 'first rec is an object'); t.equal(typeof (recs[0]), 'object', 'first rec is an object');
t.equal(recs[1].two, 'deux', '"two" field made it through'); t.equal(recs[1].two, 'deux', '"two" field made it through');
t.end(); t.end();
}); });
@ -76,11 +78,11 @@ test('raw streams and regular streams can mix', function (t) {
log.info({two: 'deux'}, 'second'); log.info({two: 'deux'}, 'second');
t.equal(rawRecs.length, 2); t.equal(rawRecs.length, 2);
t.equal(typeof(rawRecs[0]), 'object', 'first rawRec is an object'); t.equal(typeof (rawRecs[0]), 'object', 'first rawRec is an object');
t.equal(rawRecs[1].two, 'deux', '"two" field made it through'); t.equal(rawRecs[1].two, 'deux', '"two" field made it through');
t.equal(nonRawRecs.length, 2); t.equal(nonRawRecs.length, 2);
t.equal(typeof(nonRawRecs[0]), 'string', 'first nonRawRec is a string'); t.equal(typeof (nonRawRecs[0]), 'string', 'first nonRawRec is a string');
t.end(); t.end();
}); });
@ -117,11 +119,11 @@ test('child adding a non-raw stream works', function (t) {
t.equal(rawRecs.length, 1, t.equal(rawRecs.length, 1,
format('rawRecs length should be 1 (is %d)', rawRecs.length)); format('rawRecs length should be 1 (is %d)', rawRecs.length));
t.equal(typeof(rawRecs[0]), 'object', 'rawRec entry is an object'); t.equal(typeof (rawRecs[0]), 'object', 'rawRec entry is an object');
t.equal(rawRecs[0].two, 'deux', '"two" field made it through'); t.equal(rawRecs[0].two, 'deux', '"two" field made it through');
t.equal(nonRawRecs.length, 1); t.equal(nonRawRecs.length, 1);
t.equal(typeof(nonRawRecs[0]), 'string', 'first nonRawRec is a string'); t.equal(typeof (nonRawRecs[0]), 'string', 'first nonRawRec is a string');
t.end(); t.end();
}); });