Fix logging of caps
MODIFY
lib/appium.js
lib/appium.js
@@ -14,8 +14,8 @@ import { WindowsDriver } from 'appium-windows-driver';
import { MacDriver } from 'appium-mac-driver';
import { EspressoDriver } from 'appium-espresso-driver';
import B from 'bluebird';
-import util from 'util';
import AsyncLock from 'async-lock';
+import { inspectObject } from './utils';
const sessionsListGuard = new AsyncLock();
@@ -169,10 +169,7 @@ class AppiumDriver extends BaseDriver {
`Creating new ${driver.name} session`;
log.info(introString);
log.info('Capabilities:');
- util.inspect(caps);
- for (let [cap, value] of _.toPairs(caps)) {
- log.info(` ${cap}: ${util.inspect(value)}`);
- }
+ inspectObject(caps);
}
async createSession (caps, reqCaps) {

MODIFY
lib/main.js
lib/main.js
@@ -12,7 +12,7 @@ import { showConfig, checkNodeOk, validateServerArgs,
getDeprecatedArgs, getGitRev, APPIUM_VER } from './config';
import getAppiumRouter from './appium';
import registerNode from './grid-register';
-import util from 'util';
+import { inspectObject } from './utils';
async function preflightChecks (parser, args, throwInsteadOfExit = false) {
@@ -48,42 +48,14 @@ function logDeprecationWarning (deprecatedArgs) {
}
function logNonDefaultArgsWarning (args) {
- // cleanly print out the default arguments, allowing for prefix and timestamp
- function getValueArray (obj, indent = ' ') {
- if (!_.isObject(obj)) {
- return [obj];
- }
-
- let strArr = ['{'];
- for (let [arg, value] of _.toPairs(obj)) {
- if (!_.isObject(value)) {
- strArr.push(`${indent} ${arg}: ${value}`);
- } else {
- value = getValueArray(value, `${indent} `);
- strArr.push(`${indent} ${arg}: ${value.shift()}`);
- strArr.push(...value);
- }
- }
- strArr.push(`${indent}}`);
- return strArr;
- }
logger.info('Non-default server args:');
- for (let [arg, value] of _.toPairs(args)) {
- value = getValueArray(value);
- logger.info(` ${arg}: ${value.shift()}`);
- for (let val of value) {
- logger.info(val);
- }
- }
+ inspectObject(args);
}
function logDefaultCapabilitiesWarning (caps) {
logger.info('Default capabilities, which will be added to each request ' +
'unless overridden by desired capabilities:');
- util.inspect(caps);
- for (let [cap, value] of _.toPairs(caps)) {
- logger.info(` ${cap}: ${util.inspect(value)}`);
- }
+ inspectObject(caps);
}
async function logStartupInfo (parser, args) {

ADD
lib/utils.js
+import _ from 'lodash';
+import logger from './logger';
+
+
+function inspectObject (args) {
+ function getValueArray (obj, indent = ' ') {
+ if (!_.isObject(obj)) {
+ return [obj];
+ }
+
+ let strArr = ['{'];
+ for (let [arg, value] of _.toPairs(obj)) {
+ if (!_.isObject(value)) {
+ strArr.push(`${indent} ${arg}: ${value}`);
+ } else {
+ value = getValueArray(value, `${indent} `);
+ strArr.push(`${indent} ${arg}: ${value.shift()}`);
+ strArr.push(...value);
+ }
+ }
+ strArr.push(`${indent}}`);
+ return strArr;
+ }
+ for (let [arg, value] of _.toPairs(args)) {
+ value = getValueArray(value);
+ logger.info(` ${arg}: ${value.shift()}`);
+ for (let val of value) {
+ logger.info(val);
+ }
+ }
+}
+
+export { inspectObject };

Fix logging of caps