如何安装 bunyan 记录器,以便他们可以在路线上为自己的记录器获取 bunyan 的孩子?
试图:
import * as restify from 'restify';
import {createLogger} from 'bunyan';
let app = restify.createServer();
app.use(restify.queryParser());
app.use(restify.bodyParser());
app.on('after', restify.auditLogger({
log: createLogger({
name: 'audit',
stream: process.stdout
})
}));
app.get('/foo', (req, res, next) => {
req.getLogger('foo').info('bar');
res.json({});
});
app.listen(process.env.PORT || 3000, function() {
console.info('%s listening at %s', app.name, app.url);
});
req.getLogger
应该按照http://restify.com/#getloggercomponent工作,但也许app.use
还需要一个步骤,但文档中没有提到?