Skip to content

Commit fcd914b

Browse files
committed
Revert "Log objects rather than JSON stringified objects" (parse-community#1995)
1 parent db76aa3 commit fcd914b

File tree

4 files changed

+12
-27
lines changed

4 files changed

+12
-27
lines changed

README.md

+2-12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ That's it! You are now running a standalone version of Parse Server on your mach
2828

2929
**Using a remote MongoDB?** Pass the `--databaseURI DATABASE_URI` parameter when starting `parse-server`. Learn more about configuring Parse Server [here](#configuration). For a full list of available options, run `parse-server --help`.
3030

31+
**Want logs to be in placed in other folder?** Pass the `PARSE_SERVER_LOGS_FOLDER` environment variable when starting `parse-server`. Usage :- `PARSE_SERVER_LOGS_FOLDER='<path-to-logs-folder>' parse-server --appId APPLICATION_ID --masterKey MASTER_KEY`
32+
3133
### Saving your first object
3234

3335
Now that you're running Parse Server, it is time to save your first object. We'll use the [REST API](https://parse.com/docs/rest/guide), but you can easily do the same using any of the [Parse SDKs](https://parseplatform.github.io/#sdks). Run the following:
@@ -143,18 +145,6 @@ app.listen(1337, function() {
143145

144146
For a full list of available options, run `parse-server --help`.
145147

146-
## Logging
147-
148-
Parse Server will, by default, will log:
149-
* to the console
150-
* daily rotating files as new line delimited JSON
151-
152-
Logs are also be viewable in Parse Dashboard but it only displays the `messages` field of each log entry. For example, with VERBOSE set this will exclude `origin` on each request.
153-
154-
**Want to log each request and response?** Set the `VERBOSE` environment variable when starting `parse-server`. Usage :- `VERBOSE='1' parse-server --appId APPLICATION_ID --masterKey MASTER_KEY`
155-
156-
**Want logs to be in placed in other folder?** Pass the `PARSE_SERVER_LOGS_FOLDER` environment variable when starting `parse-server`. Usage :- `PARSE_SERVER_LOGS_FOLDER='<path-to-logs-folder>' parse-server --appId APPLICATION_ID --masterKey MASTER_KEY`
157-
158148
# Documentation
159149

160150
The full documentation for Parse Server is available in the [wiki](https://github.com/ParsePlatform/parse-server/wiki). The [Parse Server guide](https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide) is a good place to get started. If you're interested in developing for Parse Server, the [Development guide](https://github.com/ParsePlatform/parse-server/wiki/Development-Guide) will help you get set up.

spec/FileLoggerAdapter.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('verbose logs', () => {
6262
level: 'verbose'
6363
});
6464
}).then((results) => {
65-
expect(results[1].body.password).toEqual("********");
65+
expect(results[1].message.includes('"password": "********"')).toEqual(true);
6666
var headers = {
6767
'X-Parse-Application-Id': 'test',
6868
'X-Parse-REST-API-Key': 'rest'
@@ -77,7 +77,7 @@ describe('verbose logs', () => {
7777
size: 100,
7878
level: 'verbose'
7979
}).then((results) => {
80-
expect(results[1].url.includes('password=********')).toEqual(true);
80+
expect(results[1].message.includes('password=********')).toEqual(true);
8181
done();
8282
});
8383
});
@@ -95,7 +95,7 @@ describe('verbose logs', () => {
9595
level: 'verbose'
9696
});
9797
}).then((results) => {
98-
expect(results[1].body.password).toEqual("pw");
98+
expect(results[1].message.includes('"password": "pw"')).toEqual(true);
9999
done();
100100
});
101101
});

src/PromiseRouter.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,15 @@ export default class PromiseRouter {
154154
// just treat it like it resolved to an error.
155155
function makeExpressHandler(promiseHandler) {
156156
return function(req, res, next) {
157-
var url = maskSensitiveUrl(req);
158157
try {
159-
log.verbose(`REQUEST for [${req.method}] ${url}`, {
160-
method: req.method,
161-
url: url,
162-
headers: req.headers,
163-
body: maskSensitiveBody(req)
164-
});
158+
log.verbose(req.method, maskSensitiveUrl(req), req.headers,
159+
JSON.stringify(maskSensitiveBody(req), null, 2));
165160
promiseHandler(req).then((result) => {
166161
if (!result.response && !result.location && !result.text) {
167162
log.error('the handler did not include a "response" or a "location" field');
168163
throw 'control should not get here';
169164
}
170-
log.verbose(`RESPONSE from [${req.method}] ${url}`, {result: result});
165+
log.verbose(JSON.stringify(result, null, 2));
171166

172167
var status = result.status || 200;
173168
res.status(status);
@@ -191,11 +186,11 @@ function makeExpressHandler(promiseHandler) {
191186
}
192187
res.json(result.response);
193188
}, (e) => {
194-
log.error(`Error generating response. ${e}`, {error: e});
189+
log.verbose('error:', e);
195190
next(e);
196191
});
197192
} catch (e) {
198-
log.error(`Error handling request: ${e}`, {error: e});
193+
log.verbose('exception:', e);
199194
next(e);
200195
}
201196
}

src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import winston from 'winston';
12
import ParseServer from './ParseServer';
2-
import logger from './logger';
33
import S3Adapter from 'parse-server-s3-adapter'
44
import FileSystemAdapter from 'parse-server-fs-adapter'
55
import TestUtils from './TestUtils';
@@ -16,4 +16,4 @@ _ParseServer.createLiveQueryServer = ParseServer.createLiveQueryServer;
1616
let GCSAdapter = useExternal('GCSAdapter', 'parse-server-gcs-adapter');
1717

1818
export default ParseServer;
19-
export { S3Adapter, GCSAdapter, FileSystemAdapter, TestUtils, _ParseServer as ParseServer, logger };
19+
export { S3Adapter, GCSAdapter, FileSystemAdapter, TestUtils, _ParseServer as ParseServer };

0 commit comments

Comments
 (0)