Skip to content

Commit

Permalink
Revert "Clean up default log printing to prevent clutter (wix#2642)"
Browse files Browse the repository at this point in the history
This reverts commit 7e2ed5d.
  • Loading branch information
d4vidi committed Feb 15, 2021
1 parent 5cc8ada commit b8f8249
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 28 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img alt="Detox" width=380 src="docs/img/DetoxLogo.png"/>
<img alt="Detox" width=380 src="https://raw.githubusercontent.com/wix/Detox/master/docs/img/DetoxLogo.png"/>
</p>
<h1 align="center">
Detox
Expand All @@ -8,7 +8,7 @@
<b>Gray box end-to-end testing and automation library for mobile apps.</b>
</p>
<p align="center">
<img alt="Demo" src="docs/img/Detox.gif"/>
<img alt="Demo" src="http://i.imgur.com/eoaDEYp.gif"/>
</p>
<h1></h1>

Expand Down
2 changes: 1 addition & 1 deletion detox/local-cli/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function launchTestRunner({ argv, env, specs }) {
specs.join(' ')
].join(' ');

log.debug(printEnvironmentVariables(env) + fullCommand);
log.info(printEnvironmentVariables(env) + fullCommand);

cp.execSync(fullCommand, {
stdio: 'inherit',
Expand Down
15 changes: 3 additions & 12 deletions detox/runners/jest/SpecReporterImpl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const chalk = require('chalk').default;
const { traceln } = require('./utils/stdout');
const logger = require('../../src/utils/logger');
const log = logger.child();
const log = require('../../src/utils/logger').child();

const RESULT_SKIPPED = chalk.yellow('SKIPPED');
const RESULT_FAILED = chalk.red('FAIL');
Expand Down Expand Up @@ -30,9 +29,7 @@ class SpecReporter {
}

onTestStart({description, invocations = 1}) {
if(/^(debug|trace)$/.test(logger.getDetoxLevel())) {
this._traceTest({description, invocations});
}
this._traceTest({description, invocations});
}

onTestEnd({description, invocations = 1}, result) {
Expand Down Expand Up @@ -61,17 +58,11 @@ class SpecReporter {
}

_traceTest({description, invocations}, _status = undefined) {
if(_status === RESULT_SKIPPED && !/^(debug|trace)$/.test(logger.getDetoxLevel())) {
return;
}

const testDescription = chalk.gray(description);
const retriesDescription = (invocations > 1) ? chalk.gray(` [Retry #${invocations - 1}]`) : '';
const status = chalk.gray(_status ? ` [${_status}]` : '');
const desc = this._suitesDesc + testDescription + retriesDescription + status;

const loggingFunc = _status === RESULT_FAILED ? log.error.bind(log) : log.info.bind(log);
loggingFunc({event: 'SPEC_STATE_CHANGE'}, desc);
log.info({event: 'SPEC_STATE_CHANGE'}, desc);
}
}

Expand Down
2 changes: 1 addition & 1 deletion detox/runners/jest/WorkerAssignReporterImpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class WorkerAssignReporterImpl {
? chalk.redBright('undefined')
: chalk.blueBright(deviceName);

log.trace({event: 'WORKER_ASSIGN'}, `${chalk.whiteBright(workerName)} is assigned to ${formattedDeviceName}`);
log.info({event: 'WORKER_ASSIGN'}, `${chalk.whiteBright(workerName)} is assigned to ${formattedDeviceName}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion detox/src/devices/drivers/ios/SimulatorDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class SimulatorDriver extends IosDriver {
`xcrun simctl spawn ${deviceId} launchctl list | grep -F '${bundleId}'\n`,
});
} else {
log.debug({}, `Found the app (${bundleId}) with process ID = ${pid}. Proceeding...`);
log.info({}, `Found the app (${bundleId}) with process ID = ${pid}. Proceeding...`);
}

await this.emitter.emit('launchApp', {bundleId, deviceId, launchArgs, pid});
Expand Down
2 changes: 1 addition & 1 deletion detox/src/devices/drivers/ios/tools/AppleSimUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class AppleSimUtils {
const predicate = `process == "${CFBundleExecutable}"`;
const command = `/usr/bin/xcrun simctl spawn ${udid} log stream --level debug --style compact --predicate '${predicate}'`;

log.debug(`${bundleId} launched. To watch simulator logs, run:\n ${command}`);
log.info(`${bundleId} launched. To watch simulator logs, run:\n ${command}`);
}

_parseLaunchId(result) {
Expand Down
2 changes: 1 addition & 1 deletion detox/src/server/DetoxServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DetoxServer {
});
this.sessions = {};
this.standalone = standalone;
logger.debug(`server listening on localhost:${this.wss.options.port}...`);
logger.info(`server listening on localhost:${this.wss.options.port}...`);
this._setup();
}

Expand Down
2 changes: 1 addition & 1 deletion detox/src/utils/customConsoleLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function overrideConsoleMethods(console, bunyanLogger) {

override(console, 'log', log.info.bind(log));
override(console, 'warn', log.warn.bind(log));
override(console, 'trace', log.trace.bind(log));
override(console, 'trace', log.info.bind(log));
override(console, 'error', log.error.bind(log));
override(console, 'debug', log.debug.bind(log));
override(console, 'assert', log.error.bind(log));
Expand Down
9 changes: 4 additions & 5 deletions detox/src/utils/customConsoleLogger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ describe('customConsoleLogger.overrideConsoleMethods(console, bunyanLogger)', ()
};

bunyanLogger = {
error: jest.fn(),
debug: jest.fn(),
warn: jest.fn(),
info: jest.fn(),
debug: jest.fn(),
trace: jest.fn(),
error: jest.fn(),
};
});

Expand Down Expand Up @@ -58,9 +57,9 @@ describe('customConsoleLogger.overrideConsoleMethods(console, bunyanLogger)', ()
expect(bunyanLogger.warn).toHaveBeenCalledWith(USER_LOG_EVENT, expectedOrigin, '\n', 'Warning 301');
});

it('should connect: console.trace -> logger.trace', () => {
it('should connect: console.trace -> logger.info', () => {
fakeConsole.trace('TraceMe %d', 100500);
expect(bunyanLogger.trace).toHaveBeenCalledWith(USER_LOG_EVENT, expectedOrigin, '\n Trace:', 'TraceMe 100500', expectedStackDump);
expect(bunyanLogger.info).toHaveBeenCalledWith(USER_LOG_EVENT, expectedOrigin, '\n Trace:', 'TraceMe 100500', expectedStackDump);
});

it('should connect: console.error -> logger.error', () => {
Expand Down
5 changes: 2 additions & 3 deletions detox/src/utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const bunyanDebugStream = require('bunyan-debug-stream');
const argparse = require('./argparse');
const temporaryPath = require('../artifacts/utils/temporaryPath');
const customConsoleLogger = require('./customConsoleLogger');
const isRunningInBand = !!global.DETOX_CLI || argparse.getArgValue('maxWorkers') == '1';

function adaptLogLevelName(level) {
switch (level) {
Expand Down Expand Up @@ -36,8 +35,8 @@ function tryOverrideConsole(logger, global) {
function createPlainBunyanStream({ logPath, level }) {
const options = {
showDate: false,
showLoggerName: !isRunningInBand,
showPid: !isRunningInBand,
showLoggerName: true,
showPid: true,
showMetadata: false,
basepath: __dirname,
out: process.stderr,
Expand Down
Binary file removed docs/img/Detox.gif
Binary file not shown.

0 comments on commit b8f8249

Please sign in to comment.