Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Logger): Handle interpolating stdout #7114

Merged
merged 3 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- NEW: LiveQuery support for $and, $nor, $containedBy, $geoWithin, $geoIntersects queries [#7113](https://github.com/parse-community/parse-server/pull/7113). Thanks to [dplewis](https://github.com/dplewis)

### 4.5.0
Expand Down
11 changes: 11 additions & 0 deletions spec/WinstonLoggerAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
2 changes: 1 addition & 1 deletion src/Adapters/Logger/WinstonLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function configureTransports(options) {
colorize: true,
name: 'console',
silent,
format: consoleFormat,
format: format.combine(format.splat(), consoleFormat),
},
options
);
Expand Down
2 changes: 1 addition & 1 deletion src/LiveQuery/ParseLiveQueryServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down