From 42e99323ee82718a8cb9fa6baf488c67e92c228d Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Sat, 31 May 2014 22:25:06 -0700 Subject: [PATCH] 'make check' --- CHANGES.md | 3 ++- examples/specific-level-streams.js | 17 ++++++++--------- lib/bunyan.js | 4 ++-- test/process-exit.js | 16 ++++++++-------- test/process-exit.test.js | 17 +++++++++-------- 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 23639c3..e6acff4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,8 @@ Known issues: ## 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 diff --git a/examples/specific-level-streams.js b/examples/specific-level-streams.js index be7cafa..dd77a1d 100644 --- a/examples/specific-level-streams.js +++ b/examples/specific-level-streams.js @@ -35,19 +35,19 @@ SpecificLevelStream.prototype.write = function (rec) { var log1 = bunyan.createLogger({ name: 'use-case-1', - streams: [{ + streams: [ { level: 'trace', type: 'raw', stream: new SpecificLevelStream( ['trace', 'debug', 'info', 'warn'], process.stdout) - },{ + }, { level: 'error', type: 'raw', stream: new SpecificLevelStream( ['error'], process.stderr) - }] + } ] }); 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({ name: 'use-case-2', - streams: [{ + streams: [ { level: 'info', type: 'raw', stream: new SpecificLevelStream( ['info'], - fs.createWriteStream('specific-level-stream-http.log', + fs.createWriteStream('specific-level-streams-http.log', {flags: 'a', encoding: 'utf8'})) - },{ + }, { level: 'warn', - path: 'specific-level-stream-http.err.log' - } - ] + path: 'specific-level-streams-http.err.log' + } ] }); log2.info('200 GET /blah'); diff --git a/lib/bunyan.js b/lib/bunyan.js index aba58a8..cd9555c 100644 --- a/lib/bunyan.js +++ b/lib/bunyan.js @@ -1017,8 +1017,8 @@ RotatingFileStream.prototype._setupNextRot = function () { this.timeout = setTimeout( function () { self.rotate(); }, this.rotAt - Date.now()); - if (typeof this.timeout.unref === 'function') { - this.timeout.unref(); + if (typeof (this.timeout.unref) === 'function') { + this.timeout.unref(); } } diff --git a/test/process-exit.js b/test/process-exit.js index 5e547c9..d273812 100644 --- a/test/process-exit.js +++ b/test/process-exit.js @@ -1,11 +1,11 @@ var bunyan = require('../lib/bunyan'); var log = bunyan.createLogger({ - name: 'default', - streams: [{ - type: 'rotating-file', - path: __dirname + '/log.test.rot.log', - period: '1d', - count: 7 - }] + name: 'default', + streams: [ { + type: 'rotating-file', + path: __dirname + '/log.test.rot.log', + period: '1d', + count: 7 + } ] }); -console.log('done'); \ No newline at end of file +console.log('done'); diff --git a/test/process-exit.test.js b/test/process-exit.test.js index 954cf46..5d480df 100644 --- a/test/process-exit.test.js +++ b/test/process-exit.test.js @@ -7,15 +7,16 @@ var exec = require('child_process').exec; // node-tap API if (require.cache[__dirname + '/tap4nodeunit.js']) - delete require.cache[__dirname + '/tap4nodeunit.js']; + delete require.cache[__dirname + '/tap4nodeunit.js']; var tap4nodeunit = require('./tap4nodeunit.js'); var test = tap4nodeunit.test; test('log with rotating file stream will terminate gracefully', function (t) { - exec('node ' +__dirname + '/process-exit.js', {timeout: 1000}, function(err, stdout, stderr) { - t.ifError(err); - t.equal(stdout, 'done\n'); - t.equal(stderr, ''); - t.end(); - }); -}); \ No newline at end of file + exec('node ' +__dirname + '/process-exit.js', {timeout: 1000}, + function (err, stdout, stderr) { + t.ifError(err); + t.equal(stdout, 'done\n'); + t.equal(stderr, ''); + t.end(); + }); +});