Skip to content

Commit a2d332f

Browse files
authored
Fix #6179 Initializing default logger (#6186)
* Fix #6179 Initializing default logger Fixes: #6179 Removes unnessary logs * fix typo * if error just write to console
1 parent 78f76cb commit a2d332f

File tree

4 files changed

+40
-46
lines changed

4 files changed

+40
-46
lines changed

src/Adapters/Auth/twitter.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Helper functions for accessing the twitter API.
22
var OAuth = require('./OAuth1Client');
33
var Parse = require('parse/node').Parse;
4-
var logger = require('../../logger').default;
54

65
// Returns a promise that fulfills iff this user id is valid.
76
function validateAuthData(authData, options) {
@@ -37,10 +36,6 @@ function handleMultipleConfigurations(authData, options) {
3736
if (Array.isArray(options)) {
3837
const consumer_key = authData.consumer_key;
3938
if (!consumer_key) {
40-
logger.error(
41-
'Twitter Auth',
42-
'Multiple twitter configurations are available, by no consumer_key was sent by the client.'
43-
);
4439
throw new Parse.Error(
4540
Parse.Error.OBJECT_NOT_FOUND,
4641
'Twitter auth is invalid for this user.'
@@ -51,10 +46,6 @@ function handleMultipleConfigurations(authData, options) {
5146
});
5247

5348
if (options.length == 0) {
54-
logger.error(
55-
'Twitter Auth',
56-
'Cannot find a configuration for the provided consumer_key'
57-
);
5849
throw new Parse.Error(
5950
Parse.Error.OBJECT_NOT_FOUND,
6051
'Twitter auth is invalid for this user.'

src/Adapters/Auth/vkontakte.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
const httpsRequest = require('./httpsRequest');
66
var Parse = require('parse/node').Parse;
7-
var logger = require('../../logger').default;
87

98
// Returns a promise that fulfills iff this user id is valid.
109
function validateAuthData(authData, params) {
@@ -28,7 +27,6 @@ function validateAuthData(authData, params) {
2827
);
2928
});
3029
}
31-
logger.error('Vk Auth', 'Vk appIds or appSecret is incorrect.');
3230
throw new Parse.Error(
3331
Parse.Error.OBJECT_NOT_FOUND,
3432
'Vk appIds or appSecret is incorrect.'
@@ -45,10 +43,6 @@ function vkOAuth2Request(params) {
4543
!params.appSecret ||
4644
!params.appSecret.length
4745
) {
48-
logger.error(
49-
'Vk Auth',
50-
'Vk auth is not configured. Missing appIds or appSecret.'
51-
);
5246
throw new Parse.Error(
5347
Parse.Error.OBJECT_NOT_FOUND,
5448
'Vk auth is not configured. Missing appIds or appSecret.'

src/Adapters/Logger/WinstonLogger.js

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,45 @@ function configureTransports(options) {
1313
const silent = options.silent;
1414
delete options.silent;
1515

16-
if (!_.isNil(options.dirname)) {
17-
const parseServer = new DailyRotateFile(
18-
Object.assign(
19-
{
20-
filename: 'parse-server.info',
21-
json: true,
22-
format: format.combine(format.timestamp(), format.splat(), format.json()),
23-
},
24-
options
25-
)
26-
);
27-
parseServer.name = 'parse-server';
28-
transports.push(parseServer);
29-
30-
const parseServerError = new DailyRotateFile(
31-
Object.assign(
32-
{
33-
filename: 'parse-server.err',
34-
json: true,
35-
format: format.combine(
36-
format.timestamp(),
37-
format.splat(),
38-
format.json()
39-
),
40-
},
41-
options,
42-
{ level: 'error' }
43-
)
44-
);
45-
parseServerError.name = 'parse-server-error';
46-
transports.push(parseServerError);
16+
try {
17+
if (!_.isNil(options.dirname)) {
18+
const parseServer = new DailyRotateFile(
19+
Object.assign(
20+
{
21+
filename: 'parse-server.info',
22+
json: true,
23+
format: format.combine(
24+
format.timestamp(),
25+
format.splat(),
26+
format.json()
27+
),
28+
},
29+
options
30+
)
31+
);
32+
parseServer.name = 'parse-server';
33+
transports.push(parseServer);
34+
35+
const parseServerError = new DailyRotateFile(
36+
Object.assign(
37+
{
38+
filename: 'parse-server.err',
39+
json: true,
40+
format: format.combine(
41+
format.timestamp(),
42+
format.splat(),
43+
format.json()
44+
),
45+
},
46+
options,
47+
{ level: 'error' }
48+
)
49+
);
50+
parseServerError.name = 'parse-server-error';
51+
transports.push(parseServerError);
52+
}
53+
} catch (e) {
54+
/* */
4755
}
4856

4957
const consoleFormat = options.json ? format.json() : format.simple();

src/logger.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import defaults from './defaults';
33
import { WinstonLoggerAdapter } from './Adapters/Logger/WinstonLoggerAdapter';
44
import { LoggerController } from './Controllers/LoggerController';
55

6+
// Used for Separate Live Query Server
67
function defaultLogger() {
78
const options = {
89
logsFolder: defaults.logsFolder,

0 commit comments

Comments
 (0)