From 79820329aafa6bba741912664b1f5120cfccde9b Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Thu, 7 Jan 2021 14:33:04 -0600 Subject: [PATCH 1/2] fix(Logger): Handle interpolating stdout --- spec/WinstonLoggerAdapter.spec.js | 11 +++++++++++ src/Adapters/Logger/WinstonLogger.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/spec/WinstonLoggerAdapter.spec.js b/spec/WinstonLoggerAdapter.spec.js index 7f69660e91..ca18be3739 100644 --- a/spec/WinstonLoggerAdapter.spec.js +++ b/spec/WinstonLoggerAdapter.spec.js @@ -258,4 +258,15 @@ describe('verbose logs', () => { const log = results.find(x => x.message === 'testing verbose logs with 123'); expect(log); }); + + it('verbose logs should interpolate stdout', async () => { + await reconfigureServer({ verbose: true, silent: false, logsFolder: null }); + spyOn(process.stdout, 'write'); + const winstonLoggerAdapter = new WinstonLoggerAdapter(); + winstonLoggerAdapter.log('verbose', 'testing verbose logs with %j', { + hello: 'world', + }); + const firstLog = process.stdout.write.calls.first().args[0]; + expect(firstLog).toBe('verbose: testing verbose logs with {"hello":"world"}\n'); + }); }); diff --git a/src/Adapters/Logger/WinstonLogger.js b/src/Adapters/Logger/WinstonLogger.js index 98a86610c0..fe28660056 100644 --- a/src/Adapters/Logger/WinstonLogger.js +++ b/src/Adapters/Logger/WinstonLogger.js @@ -52,7 +52,7 @@ function configureTransports(options) { colorize: true, name: 'console', silent, - format: consoleFormat, + format: format.combine(format.splat(), consoleFormat), }, options ); From 9c0813aff31332d143e5c0da3f6e5af813baf49b Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Thu, 7 Jan 2021 14:39:08 -0600 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + src/LiveQuery/ParseLiveQueryServer.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d928e41ffb..83c0f82821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ___ - IMPROVE: Optimize queries on classes with pointer permissions. [#7061](https://github.com/parse-community/parse-server/pull/7061). Thanks to [Pedro Diaz](https://github.com/pdiaz) - FIX: request.context for afterFind triggers. [#7078](https://github.com/parse-community/parse-server/pull/7078). Thanks to [dblythy](https://github.com/dblythy) - NEW: Added convenience method Parse.Cloud.sendEmail(...) to send email via email adapter in Cloud Code. [#7089](https://github.com/parse-community/parse-server/pull/7089). Thanks to [dblythy](https://github.com/dblythy) +- FIX: Winston Logger interpolating stdout to console [#7114](https://github.com/parse-community/parse-server/pull/7114). Thanks to [dplewis](https://github.com/dplewis) ### 4.5.0 [Full Changelog](https://github.com/parse-community/parse-server/compare/4.4.0...4.5.0) diff --git a/src/LiveQuery/ParseLiveQueryServer.js b/src/LiveQuery/ParseLiveQueryServer.js index 0f00635cab..0913f0a22d 100644 --- a/src/LiveQuery/ParseLiveQueryServer.js +++ b/src/LiveQuery/ParseLiveQueryServer.js @@ -79,7 +79,7 @@ class ParseLiveQueryServer { // Register message handler for subscriber. When publisher get messages, it will publish message // to the subscribers and the handler will be called. this.subscriber.on('message', (channel, messageStr) => { - logger.verbose('Subscribe messsage %j', messageStr); + logger.verbose('Subscribe message %j', messageStr); let message; try { message = JSON.parse(messageStr);