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

Add maxLogFiles option #6296

Merged
merged 1 commit into from
Dec 24, 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
85 changes: 32 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"tv4": "1.3.0",
"uuid": "3.3.3",
"winston": "3.2.1",
"winston-daily-rotate-file": "3.10.0",
"winston-daily-rotate-file": "4.4.0",
"ws": "7.2.1"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions resources/buildConfigDefinitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ function inject(t, list) {
if (type === 'NumberOrBoolean') {
type = 'Number|Boolean';
}
if (type === 'NumberOrString') {
type = 'Number|String';
}
if (type === 'Adapter') {
const adapterType = elt.typeAnnotation.typeParameters.params[0].id.name;
type = `Adapter<${adapterType}>`;
Expand Down
2 changes: 2 additions & 0 deletions src/Adapters/Logger/WinstonLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function configureLogger({
logLevel = winston.level,
verbose = defaults.verbose,
silent = defaults.silent,
maxLogFiles,
} = {}) {
if (verbose) {
logLevel = 'verbose';
Expand All @@ -100,6 +101,7 @@ export function configureLogger({
options.dirname = logsFolder;
options.level = logLevel;
options.silent = silent;
options.maxFiles = maxLogFiles;

if (jsonLogs) {
options.json = true;
Expand Down
10 changes: 9 additions & 1 deletion src/Controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,18 @@ export function getLoggerController(
logsFolder,
verbose,
logLevel,
maxLogFiles,
silent,
loggerAdapter,
} = options;
const loggerOptions = { jsonLogs, logsFolder, verbose, logLevel, silent };
const loggerOptions = {
jsonLogs,
logsFolder,
verbose,
logLevel,
silent,
maxLogFiles,
};
const loggerControllerAdapter = loadAdapter(
loggerAdapter,
WinstonLoggerAdapter,
Expand Down
8 changes: 7 additions & 1 deletion src/Options/Definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports.ParseServerOptions = {
},
allowCustomObjectId: {
env: 'PARSE_SERVER_ALLOW_CUSTOM_OBJECT_ID',
help: 'Enable (or disable) custom objectId, defaults to false',
help: 'Enable (or disable) custom objectId',
action: parsers.booleanParser,
default: false,
},
Expand Down Expand Up @@ -230,6 +230,12 @@ module.exports.ParseServerOptions = {
help: 'Max value for limit option on queries, defaults to unlimited',
action: parsers.numberParser('maxLimit'),
},
maxLogFiles: {
env: 'PARSE_SERVER_MAX_LOG_FILES',
help:
"Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null)",
action: parsers.objectParser,
},
maxUploadSize: {
env: 'PARSE_SERVER_MAX_UPLOAD_SIZE',
help: 'Max file size for uploads, defaults to 20mb',
Expand Down
3 changes: 2 additions & 1 deletion src/Options/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @interface ParseServerOptions
* @property {Any} accountLockout account lockout policy for failed login attempts
* @property {Boolean} allowClientClassCreation Enable (or disable) client class creation, defaults to true
* @property {Boolean} allowCustomObjectId Enable (or disable) custom objectId, defaults to false
* @property {Boolean} allowCustomObjectId Enable (or disable) custom objectId
* @property {String[]} allowHeaders Add headers to Access-Control-Allow-Headers
* @property {Adapter<AnalyticsAdapter>} analyticsAdapter Adapter module for the analytics
* @property {String} appId Your Parse Application ID
Expand Down Expand Up @@ -42,6 +42,7 @@
* @property {String} masterKey Your Parse Master Key
* @property {String[]} masterKeyIps Restrict masterKey to be used by only these ips, defaults to [] (allow all ips)
* @property {Number} maxLimit Max value for limit option on queries, defaults to unlimited
* @property {Number|String} maxLogFiles Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null)
* @property {String} maxUploadSize Max file size for uploads, defaults to 20mb
* @property {Union} middleware middleware for express server, can be string or function
* @property {Boolean} mountGraphQL Mounts the GraphQL endpoint
Expand Down
3 changes: 3 additions & 0 deletions src/Options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { WSSAdapter } from '../Adapters/WebSocketServer/WSSAdapter';
// @flow
type Adapter<T> = string | any | T;
type NumberOrBoolean = number | boolean;
type NumberOrString = number | string;
type ProtectedFields = any;

export interface ParseServerOptions {
Expand Down Expand Up @@ -51,6 +52,8 @@ export interface ParseServerOptions {
verbose: ?boolean;
/* Sets the level for logs */
logLevel: ?string;
/* Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null) */
maxLogFiles: ?NumberOrString;
/* Disables console output
:ENV: SILENT */
silent: ?boolean;
Expand Down