'make check'

This commit is contained in:
Trent Mick 2014-05-31 22:25:06 -07:00
parent 7fb58aa5e4
commit 42e99323ee
5 changed files with 29 additions and 28 deletions

View file

@ -8,7 +8,8 @@ Known issues:
## bunyan 0.23.1 (not yet released) ## bunyan 0.23.1 (not yet released)
- #97 Unref rotating-file timeout which was preventing processes from exiting - [issue #97] Unref rotating-file timeout which was preventing processes from
exiting.
## bunyan 0.23.0 ## bunyan 0.23.0

View file

@ -35,19 +35,19 @@ SpecificLevelStream.prototype.write = function (rec) {
var log1 = bunyan.createLogger({ var log1 = bunyan.createLogger({
name: 'use-case-1', name: 'use-case-1',
streams: [{ streams: [ {
level: 'trace', level: 'trace',
type: 'raw', type: 'raw',
stream: new SpecificLevelStream( stream: new SpecificLevelStream(
['trace', 'debug', 'info', 'warn'], ['trace', 'debug', 'info', 'warn'],
process.stdout) process.stdout)
},{ }, {
level: 'error', level: 'error',
type: 'raw', type: 'raw',
stream: new SpecificLevelStream( stream: new SpecificLevelStream(
['error'], ['error'],
process.stderr) process.stderr)
}] } ]
}); });
log1.info('hi at info level (this should be on stdout)'); log1.info('hi at info level (this should be on stdout)');
@ -59,18 +59,17 @@ log1.error('alert alert (this should be on stderr)');
*/ */
var log2 = bunyan.createLogger({ var log2 = bunyan.createLogger({
name: 'use-case-2', name: 'use-case-2',
streams: [{ streams: [ {
level: 'info', level: 'info',
type: 'raw', type: 'raw',
stream: new SpecificLevelStream( stream: new SpecificLevelStream(
['info'], ['info'],
fs.createWriteStream('specific-level-stream-http.log', fs.createWriteStream('specific-level-streams-http.log',
{flags: 'a', encoding: 'utf8'})) {flags: 'a', encoding: 'utf8'}))
},{ }, {
level: 'warn', level: 'warn',
path: 'specific-level-stream-http.err.log' path: 'specific-level-streams-http.err.log'
} } ]
]
}); });
log2.info('200 GET /blah'); log2.info('200 GET /blah');

View file

@ -1017,8 +1017,8 @@ RotatingFileStream.prototype._setupNextRot = function () {
this.timeout = setTimeout( this.timeout = setTimeout(
function () { self.rotate(); }, function () { self.rotate(); },
this.rotAt - Date.now()); this.rotAt - Date.now());
if (typeof this.timeout.unref === 'function') { if (typeof (this.timeout.unref) === 'function') {
this.timeout.unref(); this.timeout.unref();
} }
} }

View file

@ -1,11 +1,11 @@
var bunyan = require('../lib/bunyan'); var bunyan = require('../lib/bunyan');
var log = bunyan.createLogger({ var log = bunyan.createLogger({
name: 'default', name: 'default',
streams: [{ streams: [ {
type: 'rotating-file', type: 'rotating-file',
path: __dirname + '/log.test.rot.log', path: __dirname + '/log.test.rot.log',
period: '1d', period: '1d',
count: 7 count: 7
}] } ]
}); });
console.log('done'); console.log('done');

View file

@ -7,15 +7,16 @@ var exec = require('child_process').exec;
// node-tap API // node-tap API
if (require.cache[__dirname + '/tap4nodeunit.js']) if (require.cache[__dirname + '/tap4nodeunit.js'])
delete require.cache[__dirname + '/tap4nodeunit.js']; delete require.cache[__dirname + '/tap4nodeunit.js'];
var tap4nodeunit = require('./tap4nodeunit.js'); var tap4nodeunit = require('./tap4nodeunit.js');
var test = tap4nodeunit.test; var test = tap4nodeunit.test;
test('log with rotating file stream will terminate gracefully', function (t) { test('log with rotating file stream will terminate gracefully', function (t) {
exec('node ' +__dirname + '/process-exit.js', {timeout: 1000}, function(err, stdout, stderr) { exec('node ' +__dirname + '/process-exit.js', {timeout: 1000},
t.ifError(err); function (err, stdout, stderr) {
t.equal(stdout, 'done\n'); t.ifError(err);
t.equal(stderr, ''); t.equal(stdout, 'done\n');
t.end(); t.equal(stderr, '');
}); t.end();
}); });
});