Skip to content

Commit

Permalink
Merge pull request #36 from ibm-wch/rel4.0.3
Browse files Browse the repository at this point in the history
code changes for 4.0.3
  • Loading branch information
Kevin Tapperson authored Dec 4, 2018
2 parents e6da7ee + b06ed5d commit 5bc4164
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
6 changes: 4 additions & 2 deletions CLI/lib/baseCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion CLI/package.json
Original file line number Diff line number Diff line change
@@ -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"
],
Expand Down
29 changes: 24 additions & 5 deletions authoring-api/lib/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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: {
Expand All @@ -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: {
Expand Down Expand Up @@ -935,7 +953,8 @@ const utils = {
getOldestTimestamp: getOldestTimestamp,
replaceAll: replaceAll,
reset: reset,
getUserAgent: getUserAgent
getUserAgent: getUserAgent,
getEnvNumericValue: getEnvNumericValue
};

module.exports = utils;
2 changes: 1 addition & 1 deletion authoring-api/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prod-tools",
"version": "4.0.1",
"version": "4.0.3",
"author": "IBM Corporation",
"license": "Apache-2.0",
"bugs": {
Expand Down

0 comments on commit 5bc4164

Please sign in to comment.