diff --git a/examples/http-server.js b/examples/http-server.js index 9616f5e12738cf557c4aa2989300f2c6b3d3adf5..4fe58022f07a6a1e0e2cf3572cb767c2ed632298 100644 --- a/examples/http-server.js +++ b/examples/http-server.js @@ -1,5 +1,3 @@ -const { RSA_NO_PADDING } = require('constants'); -const { readdirSync } = require('fs'); var http = require('http'); http.createServer(function (req, res) { console.log(req.method, req.url) @@ -9,8 +7,8 @@ http.createServer(function (req, res) { body += data }) req.on('end', function() { - console.log(JSON.parse(body)) - res.writeHead(200, {'Content-Type': 'text/html'}) + console.log(body) + res.writeHead(202, {'Content-Type': 'text/html'}) res.end('post received') }) diff --git a/index.js b/index.js index 778cf8b717911139e3190358b40b3f7f1a9c449b..9050ab689d2c2f217546e8dd9d47a18e08e81785 100644 --- a/index.js +++ b/index.js @@ -132,7 +132,7 @@ function Log (options) { level: this.levels[tag] }) if (this.options.graylog.mode && this.options.graylog.mode === 'http') { - this.request.post(this.options.graylog.server + ':' + this.options.graylog.port + '/gelf', {json: JSON.parse(data)}, (error, res, body) => { + this.request.post(this.options.graylog.server + ':' + this.options.graylog.port + '/gelf', {body: data}, (error, res, body) => { if (error) { console.error(error) }