2016-10-06 22:07:44 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
/*
|
|
|
|
* Time logging below the current level, which should do very little work.
|
|
|
|
*/
|
|
|
|
|
|
|
|
console.log('Time log.trace() when log level is "info":');
|
|
|
|
|
2021-06-02 21:52:18 +00:00
|
|
|
var ben = require('./ben'); // npm install ben
|
2016-10-06 22:07:44 +00:00
|
|
|
var bunyan = require('../lib/bunyan');
|
|
|
|
|
|
|
|
function Collector() {}
|
|
|
|
Collector.prototype.write = function (s) {};
|
|
|
|
|
|
|
|
var log = bunyan.createLogger({
|
|
|
|
name: 'timeguard',
|
|
|
|
level: 'info',
|
|
|
|
stream: new Collector()
|
|
|
|
});
|
|
|
|
|
|
|
|
var i = 0;
|
|
|
|
var ms, fields;
|
|
|
|
|
|
|
|
ms = ben(1e7, function () {
|
|
|
|
log.trace({ count: i++ }, 'hello');
|
|
|
|
});
|
|
|
|
console.log(' - log.trace: %dms per iteration', ms);
|