Refactor logging to provide common logger from LoggerAdapter (#2478)
* Refactor logging to provide common logger from LoggerAdapter Move logger logic de WinstonLoggerAdapter Further improvements in configuration Use logger instead of getLogger - Removes PLog module Reverts name changes nits * Adds additional logging levels as requirements * Adds tests for logging configuration * removes flaky test * investigate... * further investigation * Adds silent option to disable console output * Restores logs with VERBOSE in tests * Expose controller instead of adapter, reduces method requirements for adapter * Shuffles initializations around * Fix doc * Load cloudCode last to make sure the logger is available * Adds test to make sure we can load an adapter from npm module * extract defaults * Adds defaultMongoURI to defaults * fix defaults values * Proper error for PG failures * Disable flaky test
This commit is contained in:
@@ -878,6 +878,8 @@ DatabaseController.prototype.addPointerPermissions = function(schema, className,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: create indexes on first creation of a _User object. Otherwise it's impossible to
|
||||
// have a Parse app without it having a _User collection.
|
||||
DatabaseController.prototype.performInitizalization = function() {
|
||||
const requiredUserFields = { fields: { ...SchemaController.defaultColumns._Default, ...SchemaController.defaultColumns._User } };
|
||||
|
||||
|
||||
@@ -16,7 +16,35 @@ export const LogOrder = {
|
||||
}
|
||||
|
||||
export class LoggerController extends AdaptableController {
|
||||
|
||||
log(level, args) {
|
||||
args = [].concat(level, [...args]);
|
||||
this.adapter.log.apply(this.adapter, args);
|
||||
}
|
||||
|
||||
info() {
|
||||
return this.log('info', arguments);
|
||||
}
|
||||
|
||||
error() {
|
||||
return this.log('error', arguments);
|
||||
}
|
||||
|
||||
warn() {
|
||||
return this.log('warn', arguments);
|
||||
}
|
||||
|
||||
verbose() {
|
||||
return this.log('verbose', arguments);
|
||||
}
|
||||
|
||||
debug() {
|
||||
return this.log('debug', arguments);
|
||||
}
|
||||
|
||||
silly() {
|
||||
return this.log('silly', arguments);
|
||||
}
|
||||
// check that date input is valid
|
||||
static validDateTime(date) {
|
||||
if (!date) {
|
||||
@@ -60,6 +88,10 @@ export class LoggerController extends AdaptableController {
|
||||
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED,
|
||||
'Logger adapter is not availabe');
|
||||
}
|
||||
if (typeof this.adapter.query !== 'function') {
|
||||
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED,
|
||||
'Querying logs is not supported with this adapter');
|
||||
}
|
||||
options = LoggerController.parseOptions(options);
|
||||
return this.adapter.query(options);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,12 @@ const SCHEMA_CACHE_PREFIX = "__SCHEMA";
|
||||
const ALL_KEYS = "__ALL_KEYS";
|
||||
|
||||
import { randomString } from '../cryptoUtils';
|
||||
import defaults from '../defaults';
|
||||
|
||||
export default class SchemaCache {
|
||||
cache: Object;
|
||||
|
||||
constructor(cacheController, ttl = 30) {
|
||||
constructor(cacheController, ttl = defaults.schemaCacheTTL) {
|
||||
this.ttl = ttl;
|
||||
if (typeof ttl == 'string') {
|
||||
this.ttl = parseInt(ttl);
|
||||
|
||||
Reference in New Issue
Block a user