GT2/GT2-iOS/node_modules/logfmt/examples/restify_pipe_to_stdout.js

21 lines
447 B
JavaScript
Raw Normal View History

2018-02-12 17:26:06 +00:00
var restify = require('restify');
var through = require('through');
var logfmt = require('../logfmt');
var server = restify.createServer({
name: 'logfmt-test-server'
})
server.use(logfmt.bodyParserStream());
server.use(logfmt.requestLogger());
server.post('/logs', function(req, res, next){
req.body.pipe(through(function(line){
console.log(JSON.stringify(line));
}))
res.send(201, 'OK');
return next();
})
server.listen(3000);