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 #6179 Initializing default logger #6186

Merged
merged 3 commits into from
Nov 7, 2019
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
9 changes: 0 additions & 9 deletions src/Adapters/Auth/twitter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Helper functions for accessing the twitter API.
var OAuth = require('./OAuth1Client');
var Parse = require('parse/node').Parse;
var logger = require('../../logger').default;

// Returns a promise that fulfills iff this user id is valid.
function validateAuthData(authData, options) {
Expand Down Expand Up @@ -37,10 +36,6 @@ function handleMultipleConfigurations(authData, options) {
if (Array.isArray(options)) {
const consumer_key = authData.consumer_key;
if (!consumer_key) {
logger.error(
'Twitter Auth',
'Multiple twitter configurations are available, by no consumer_key was sent by the client.'
);
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Twitter auth is invalid for this user.'
Expand All @@ -51,10 +46,6 @@ function handleMultipleConfigurations(authData, options) {
});

if (options.length == 0) {
logger.error(
'Twitter Auth',
'Cannot find a configuration for the provided consumer_key'
);
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Twitter auth is invalid for this user.'
Expand Down
6 changes: 0 additions & 6 deletions src/Adapters/Auth/vkontakte.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

const httpsRequest = require('./httpsRequest');
var Parse = require('parse/node').Parse;
var logger = require('../../logger').default;

// Returns a promise that fulfills iff this user id is valid.
function validateAuthData(authData, params) {
Expand All @@ -28,7 +27,6 @@ function validateAuthData(authData, params) {
);
});
}
logger.error('Vk Auth', 'Vk appIds or appSecret is incorrect.');
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Vk appIds or appSecret is incorrect.'
Expand All @@ -45,10 +43,6 @@ function vkOAuth2Request(params) {
!params.appSecret ||
!params.appSecret.length
) {
logger.error(
'Vk Auth',
'Vk auth is not configured. Missing appIds or appSecret.'
);
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Vk auth is not configured. Missing appIds or appSecret.'
Expand Down
70 changes: 39 additions & 31 deletions src/Adapters/Logger/WinstonLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,45 @@ function configureTransports(options) {
const silent = options.silent;
delete options.silent;

if (!_.isNil(options.dirname)) {
const parseServer = new DailyRotateFile(
Object.assign(
{
filename: 'parse-server.info',
json: true,
format: format.combine(format.timestamp(), format.splat(), format.json()),
},
options
)
);
parseServer.name = 'parse-server';
transports.push(parseServer);

const parseServerError = new DailyRotateFile(
Object.assign(
{
filename: 'parse-server.err',
json: true,
format: format.combine(
format.timestamp(),
format.splat(),
format.json()
),
},
options,
{ level: 'error' }
)
);
parseServerError.name = 'parse-server-error';
transports.push(parseServerError);
try {
if (!_.isNil(options.dirname)) {
const parseServer = new DailyRotateFile(
Object.assign(
{
filename: 'parse-server.info',
json: true,
format: format.combine(
format.timestamp(),
format.splat(),
format.json()
),
},
options
)
);
parseServer.name = 'parse-server';
transports.push(parseServer);

const parseServerError = new DailyRotateFile(
Object.assign(
{
filename: 'parse-server.err',
json: true,
format: format.combine(
format.timestamp(),
format.splat(),
format.json()
),
},
options,
{ level: 'error' }
)
);
parseServerError.name = 'parse-server-error';
transports.push(parseServerError);
}
} catch (e) {
/* */
}

const consoleFormat = options.json ? format.json() : format.simple();
Expand Down
1 change: 1 addition & 0 deletions src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import defaults from './defaults';
import { WinstonLoggerAdapter } from './Adapters/Logger/WinstonLoggerAdapter';
import { LoggerController } from './Controllers/LoggerController';

// Used for Separate Live Query Server
function defaultLogger() {
const options = {
logsFolder: defaults.logsFolder,
Expand Down