Name: js-handler/node_modules/restify/node_modules/bunyan/tools/timesrc.js
| 1: | #!/usr/bin/env node |
| 2: | /* |
| 3: | * Time 'src' fields (getting log call source info). This is expensive. |
| 4: | */ |
| 5: | |
| 6: | console.log('Time adding "src" field with call source info:'); |
| 7: | |
| 8: | var ben = require('ben'); // npm install ben |
| 9: | var Logger = require('../lib/bunyan'); |
| 10: | |
| 11: | var records = []; |
| 12: | function Collector() { |
| 13: | } |
| 14: | Collector.prototype.write = function (s) { |
| 15: | //records.push(s); |
| 16: | } |
| 17: | var collector = new Collector(); |
| 18: | |
| 19: | var logwith = new Logger({ |
| 20: | name: 'with-src', |
| 21: | src: true, |
| 22: | stream: collector |
| 23: | }); |
| 24: | |
| 25: | var ms = ben(1e5, function () { |
| 26: | logwith.info('hi'); |
| 27: | }); |
| 28: | console.log(' - log.info with src: %dms per iteration', ms); |
| 29: | |
| 30: | var logwithout = new Logger({ |
| 31: | name: 'without-src', |
| 32: | stream: collector |
| 33: | }); |
| 34: | var ms = ben(1e5, function () { |
| 35: | logwithout.info('hi'); |
| 36: | }); |
| 37: | console.log(' - log.info without src: %dms per iteration', ms); |
