diff --git a/Makefile b/Makefile index 687294c..652ef0c 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,12 @@ TAP := ./node_modules/.bin/tap +#---- Files + +JSSTYLE_FILES := $(shell find lib test tools -name *.js) + + + #---- Targets all: @@ -23,3 +29,14 @@ cutarelease: versioncheck test: $(TAP) TAP=1 $(TAP) test/*.test.js +.PHONY: check-jsstyle +check-jsstyle: $(JSSTYLE_FILES) + ./tools/jsstyle -o indent=2,doxygen,unparenthesized-return=0,blank-after-start-comment=0 $(JSSTYLE_FILES) + +.PHONY: check +check: check-jsstyle + @echo "Check ok." + +.PHONY: prepush +prepush: check test + @echo "Okay to push." diff --git a/test/ctor.test.js b/test/ctor.test.js index 9abfe86..700158e 100644 --- a/test/ctor.test.js +++ b/test/ctor.test.js @@ -34,7 +34,7 @@ test('ensure Logger creation options', function (t) { {name: 'TypeError', message: 'invalid options.streams: must be an array'}, '"streams" must be an array'); - options = {name: 'foo', serializers: "a string"}; + options = {name: 'foo', serializers: 'a string'}; t.throws(function () { new Logger(options); }, {name: 'TypeError', message: 'invalid options.serializers: must be an object'}, '"serializers" cannot be a string'); @@ -87,5 +87,3 @@ test('ensure Logger child() options', function (t) { t.end(); }); - - diff --git a/tools/timechild.js b/tools/timechild.js index f5cf44f..8df5e0b 100755 --- a/tools/timechild.js +++ b/tools/timechild.js @@ -17,10 +17,10 @@ var ben = require('ben'); // npm install ben var Logger = require('../lib/bunyan'); var log = new Logger({ - name: "svc", + name: 'svc', streams: [ { - path: __dirname + "/timechild.log" + path: __dirname + '/timechild.log' }, { stream: process.stdout @@ -31,7 +31,7 @@ var log = new Logger({ } }); -console.log("Time `log.child`:"); +console.log('Time `log.child`:'); var ms = ben(1e5, function () { var child = log.child(); @@ -62,12 +62,11 @@ console.log(' - adding serializer and one field: %dms per iteration', ms); var ms = ben(1e5, function () { var child = log.child({ a: 1, - streams: [{ - stream: process.stderr - }] + streams: [ {stream: process.stderr} ] }); }); -console.log(' - adding a (stderr) stream and one field: %dms per iteration', ms); +console.log(' - adding a (stderr) stream and one field: %dms per iteration', + ms); var ms = ben(1e6, function () { var child = log.child({}, true); @@ -83,4 +82,3 @@ var ms = ben(1e6, function () { var child = log.child({a:1, b:2}, true); }); console.log(' - [fast] adding two fields: %dms per iteration', ms); - diff --git a/tools/timeguard.js b/tools/timeguard.js index 7af49a1..6d5b0f8 100755 --- a/tools/timeguard.js +++ b/tools/timeguard.js @@ -3,7 +3,7 @@ * Time logging with/without a try/catch-guard on the JSON.stringify. */ -console.log("Time try/catch-guard on JSON.stringify:"); +console.log('Time try/catch-guard on JSON.stringify:'); var ben = require('ben'); // npm install ben var Logger = require('../lib/bunyan'); @@ -11,19 +11,18 @@ var Logger = require('../lib/bunyan'); var records = []; function Collector() { } -Collector.prototype.write = function(s) { +Collector.prototype.write = function (s) { //records.push(s); } var collector = new Collector(); var log = new Logger({ - name: "timeguard", + name: 'timeguard', src: true, stream: collector }); var ms = ben(1e5, function () { - log.info("hi"); + log.info('hi'); }); console.log(' - log.info: %dms per iteration', ms); - diff --git a/tools/timesrc.js b/tools/timesrc.js index b793037..456d5db 100755 --- a/tools/timesrc.js +++ b/tools/timesrc.js @@ -3,7 +3,7 @@ * Time 'src' fields (getting log call source info). This is expensive. */ -console.log("Time adding 'src' field with call source info:"); +console.log('Time adding "src" field with call source info:'); var ben = require('ben'); // npm install ben var Logger = require('../lib/bunyan'); @@ -11,27 +11,27 @@ var Logger = require('../lib/bunyan'); var records = []; function Collector() { } -Collector.prototype.write = function(s) { +Collector.prototype.write = function (s) { //records.push(s); } var collector = new Collector(); var logwith = new Logger({ - name: "with-src", + name: 'with-src', src: true, stream: collector }); var ms = ben(1e5, function () { - logwith.info("hi"); + logwith.info('hi'); }); console.log(' - log.info with src: %dms per iteration', ms); var logwithout = new Logger({ - name: "without-src", + name: 'without-src', stream: collector }); var ms = ben(1e5, function () { - logwithout.info("hi"); + logwithout.info('hi'); }); console.log(' - log.info without src: %dms per iteration', ms);