diff --git a/CLI/lib/baseCommand.js b/CLI/lib/baseCommand.js index 178d2b4..dacefcc 100644 --- a/CLI/lib/baseCommand.js +++ b/CLI/lib/baseCommand.js @@ -1108,13 +1108,15 @@ class BaseCommand { } getLogConfig () { + const maxLogSize = utils.getEnvNumericValue('WCHTOOLS_LOG_MAX_SIZE'); + const maxBackups = utils.getEnvNumericValue('WCHTOOLS_LOG_MAX_BACKUPS'); // Set up logging for the CLI in the directory where the files exist, and then get the logger. const fileAppender = { type: 'file', filename: './' + utils.ProductAbrev + '-cli.log', category: cliLog, - maxLogSize: 30480, - backups: 3 + maxLogSize: maxLogSize, + backups: maxBackups }; const consoleAppender = { type: 'console', diff --git a/CLI/package.json b/CLI/package.json index 45e8913..6ae8d3b 100644 --- a/CLI/package.json +++ b/CLI/package.json @@ -1,7 +1,7 @@ { "name": "wchtools-cli", "description": "Command line tools for IBM Watson Content Hub", - "version": "4.0.1", + "version": "4.0.3", "keywords": [ "cli" ], diff --git a/authoring-api/lib/utils/utils.js b/authoring-api/lib/utils/utils.js index 2c15fad..0f7c826 100644 --- a/authoring-api/lib/utils/utils.js +++ b/authoring-api/lib/utils/utils.js @@ -362,6 +362,24 @@ function getErrorFromResponse (response) { return err; } +/** + * Returns the numeric value of a process environment variable, or the supplied default if it is not a numeric value. + * @param variableName the name of the process environment variable + * @param defaultValue the default value + * @returns The numeric value, the default value, or undefined. + */ +function getEnvNumericValue (variableName, defaultValue) { + let result = defaultValue; + const n = process.env[variableName]; + if (n && !Number.isNaN(n) && Number(n) >= 0 && Number.isSafeInteger(Number(n))) { + result = Number(n); + } + return result; +} + +const maxLogSize = getEnvNumericValue('WCHTOOLS_LOG_MAX_SIZE', 5242880); +const maxBackups = getEnvNumericValue('WCHTOOLS_LOG_MAX_BACKUPS', 5); + const apisLog = ProductAbrev + " " + ProductVersion; let apisLogConfig; @@ -380,8 +398,8 @@ if (buildTag && buildTag.indexOf('jenkins') !== -1) { type: 'file', filename: getApiLogPath(), category: apisLog, - maxLogSize: 500480, - backups: 5 + maxLogSize: maxLogSize, + backups: maxBackups } }, categories: { @@ -397,8 +415,8 @@ if (buildTag && buildTag.indexOf('jenkins') !== -1) { type: 'file', filename: getApiLogPath(), category: apisLog, - maxLogSize: 500480, - backups: 5 + maxLogSize: maxLogSize, + backups: maxBackups } }, categories: { @@ -935,7 +953,8 @@ const utils = { getOldestTimestamp: getOldestTimestamp, replaceAll: replaceAll, reset: reset, - getUserAgent: getUserAgent + getUserAgent: getUserAgent, + getEnvNumericValue: getEnvNumericValue }; module.exports = utils; diff --git a/authoring-api/package.json b/authoring-api/package.json index 3690330..5a925b4 100644 --- a/authoring-api/package.json +++ b/authoring-api/package.json @@ -1,7 +1,7 @@ { "name": "wchtools-api", "description": "Tools API for IBM Watson Content Hub", - "version": "4.0.1", + "version": "4.0.3", "keywords": [ "api", "tools" diff --git a/package.json b/package.json index 256496e..cbf159b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prod-tools", - "version": "4.0.1", + "version": "4.0.3", "author": "IBM Corporation", "license": "Apache-2.0", "bugs": {