From 255993f4f624614120dd68d311aebb7aff6dbb44 Mon Sep 17 00:00:00 2001 From: Xiao Gui Date: Mon, 17 Aug 2020 16:27:21 +0200 Subject: [PATCH] bugfix: json keyval has to be strictly json, and not array --- Logger.js | 2 +- package.json | 2 +- test.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Logger.js b/Logger.js index ef369bf..390009a 100644 --- a/Logger.js +++ b/Logger.js @@ -24,7 +24,7 @@ class Logger { const auth = username !== '' ? `${username}:${password}@` : '' const url = `${protocol}://${auth}${host}:${port}/${qs.escape(name)}.${qs.escape(logLevel)}` const formData = { - json: JSON.stringify(message), + json: JSON.stringify({ message }), } if (callback) { request.post({ diff --git a/package.json b/package.json index ee15fc2..818a9b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hbp-fluentd-logger", - "version": "1.0.1", + "version": "1.0.2", "description": "Thin wrapper for http(s) fluentd logging.", "main": "index.js", "files": [ diff --git a/test.js b/test.js index 3918b79..d7586ef 100644 --- a/test.js +++ b/test.js @@ -27,10 +27,10 @@ const handleRequestCallback = (err, resp, body) => { if (resp && resp.statusCode >= 400) { process.stderr.write(`fluentD logging responded error\n`) - console.log(resp) + console.log(JSON.stringify(resp)) process.stderr.write(resp.toString()) process.stderr.write('\n') } } -log.emit('info', { hello: 'world', foo: 'bar' }, handleRequestCallback) +log.emit('info', [{ hello: 'world', foo: 'bar' }, 123], handleRequestCallback)