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

21 lines
447 B
JavaScript
Raw Normal View History

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);