diff --git a/lib/plugins/run/utils/logEventGateway.js b/lib/plugins/run/utils/logEventGateway.js index a03e74756..5257ef368 100644 --- a/lib/plugins/run/utils/logEventGateway.js +++ b/lib/plugins/run/utils/logEventGateway.js @@ -27,7 +27,7 @@ const transformMessages = parsedMsg => { if (event.headers) { const text = `Received http event on path ${parsedMsg.path} ${parsedMsg.method}\n`; // TODO const ppBody = prettifyValue(event.body); - const ppBody = prettifyValue(event.data); + const ppBody = prettifyValue(event.body); const bodyText = ` ${caret} body:\n${ppBody}`; return `${text}${bodyText}\n`; } diff --git a/lib/plugins/run/utils/logEventGateway.test.js b/lib/plugins/run/utils/logEventGateway.test.js index 45f28e848..cae1f70c9 100644 --- a/lib/plugins/run/utils/logEventGateway.test.js +++ b/lib/plugins/run/utils/logEventGateway.test.js @@ -32,4 +32,22 @@ describe('logEventGateway', () => { const expected = '\u001b[38;5;173m Event Gateway | \u001b[39mRegistered function s1-f1\n'; expect(logStub.getCall(0).args[0]).to.be.equal(expected); }); + + it('format and log event received', () => { + logEventGateway( + JSON.stringify({ + level: 'debug', + ts: 1502464166.8101041, + msg: 'Event received.', + event: + '{"headers":{"Accept":["image/webp,image/apng,image/*,*/*;q=0.8"],"Accept-Encoding":["gzip, deflate, br"],"Accept-Language":["en-US,en;q=0.8"],"Cache-Control":["no-cache"],"Connection":["keep-alive"],"Pragma":["no-cache"],"Referer":["http://localhost:4000/"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"]},"query":{},"body":""}', + path: '/favicon.ico', + method: 'GET', + }) + ); + expect(logStub.calledOnce).to.be.equal(true); + const expected = // eslint-disable-next-line max-len + '\u001b[38;5;173m Event Gateway | \u001b[39mReceived http event on path /favicon.ico GET\n \u001b[38;5;173m|\u001b[39m body:\n \u001b[38;5;173m|\u001b[39m ""\n'; + expect(logStub.getCall(0).args[0]).to.be.equal(expected); + }); });