clean up console

Summary: The console was pretty spammy. This fixes some issues that were logged and changes many log statements to `console.debug` which are not shown by default.

Reviewed By: passy

Differential Revision: D9303011

fbshipit-source-id: 1102f4f8814152a45f155cb43488a515c2d4eee4
This commit is contained in:
Daniel Büchele
2018-08-14 03:01:22 -07:00
committed by Facebook Github Bot
parent eb316be4e4
commit 6f2a7dcb05
6 changed files with 37 additions and 14 deletions

View File

@@ -138,7 +138,7 @@ export default class Client extends EventEmitter {
error?: Object,
|} = rawData;
console.log(data, 'message:receive');
console.debug(data, 'message:receive');
const {id, method} = data;
@@ -240,7 +240,7 @@ export default class Client extends EventEmitter {
params,
};
console.log(data, 'message:call');
console.debug(data, 'message:call');
this.startTimingRequestResponse({method, id, params});
this.connection.fireAndForget({data: JSON.stringify(data)});
});
@@ -273,7 +273,7 @@ export default class Client extends EventEmitter {
method,
params,
};
console.log(data, 'message:send');
console.debug(data, 'message:send');
this.connection.fireAndForget({data: JSON.stringify(data)});
}

View File

@@ -103,10 +103,12 @@ export default class WelcomeScreen extends PureComponent<Props, State> {
isMounted: false,
};
timer: ?TimeoutID;
componentDidMount() {
// waiting sometime before showing the welcome screen to allow Flipper to
// connect to devices, if there are any
setTimeout(
this.timer = setTimeout(
() =>
this.setState({
isMounted: true,
@@ -115,6 +117,12 @@ export default class WelcomeScreen extends PureComponent<Props, State> {
);
}
componentWillUnmount() {
if (this.timer) {
clearTimeout(this.timer);
}
}
render() {
return (
<Container>

View File

@@ -244,6 +244,9 @@ export default class LogTable extends SonarDevicePlugin<LogsState> {
static icon = 'arrow-right';
static keyboardActions = ['clear', 'goToBottom', 'createPaste'];
initTimer: ?TimeoutID;
batchTimer: ?TimeoutID;
onKeyboardAction = (action: string) => {
if (action === 'clear') {
this.clearLogs();
@@ -384,7 +387,7 @@ export default class LogTable extends SonarDevicePlugin<LogsState> {
if (!queued) {
queued = true;
setTimeout(() => {
this.batchTimer = setTimeout(() => {
const thisBatch = batch;
batch = [];
queued = false;
@@ -421,13 +424,22 @@ export default class LogTable extends SonarDevicePlugin<LogsState> {
}
});
setTimeout(() => {
this.initTimer = setTimeout(() => {
this.setState({
initialising: false,
});
}, 2000);
}
componentWillUnmount() {
if (this.initTimer) {
clearTimeout(this.initTimer);
}
if (this.batchTimer) {
clearTimeout(this.batchTimer);
}
}
addRowIfNeeded(
rows: Array<TableBodyRow>,
row: TableBodyRow,

View File

@@ -87,7 +87,7 @@ export default class Server extends EventEmitter {
console.error(`Error opening server on port ${port}`, 'server');
})
.on('listening', () => {
console.warn(
console.debug(
`${
sslConfig ? 'Secure' : 'Certificate'
} server started on port ${port}`,
@@ -121,7 +121,7 @@ export default class Server extends EventEmitter {
conn.connectionStatus().subscribe({
onNext(payload) {
if (payload.kind == 'ERROR' || payload.kind == 'CLOSED') {
console.warn(`Device disconnected ${client.id}`, 'connection');
console.debug(`Device disconnected ${client.id}`, 'connection');
server.removeConnection(client.id);
}
},
@@ -175,7 +175,7 @@ export default class Server extends EventEmitter {
destination: string,
|} = rawData;
if (json.method === 'signCertificate') {
console.warn('CSR received from device', 'server');
console.debug('CSR received from device', 'server');
const {csr, destination} = json;
return new Single(subscriber => {
subscriber.onSubscribe();
@@ -217,7 +217,7 @@ export default class Server extends EventEmitter {
destination: string,
|} = rawData;
if (json.method === 'signCertificate') {
console.warn('CSR received from device', 'server');
console.debug('CSR received from device', 'server');
const {csr, destination} = json;
this.certificateProvider
.processCertificateSigningRequest(csr, clientData.os, destination)
@@ -242,7 +242,7 @@ export default class Server extends EventEmitter {
invariant(query, 'expected query');
const id = `${query.app}-${query.os}-${query.device}`;
console.warn(`Device connected: ${id}`, 'connection');
console.debug(`Device connected: ${id}`, 'connection');
const client = new Client(id, query, conn, this.logger);
@@ -252,7 +252,7 @@ export default class Server extends EventEmitter {
};
client.init().then(() => {
console.log(
console.debug(
`Device client initialised: ${id}. Supported plugins: ${client.plugins.join(
', ',
)}`,

View File

@@ -125,7 +125,7 @@ export default class CertificateProvider {
}
generateClientCertificate(csr: string): Promise<string> {
console.warn('Creating new client cert', logTag);
console.debug('Creating new client cert', logTag);
const csrFile = this.writeToTempFile(csr);
// Create a certificate for the client, using the details in the CSR.
return openssl('x509', {
@@ -258,7 +258,7 @@ export default class CertificateProvider {
filename: string,
contents: string,
): Promise<void> {
console.warn(`Deploying ${filename} to ${deviceId}:${app}`, logTag);
console.debug(`Deploying ${filename} to ${deviceId}:${app}`, logTag);
return this.executeCommandOnAndroid(
deviceId,
app,

View File

@@ -16,6 +16,9 @@ const {exec} = require('child_process');
const compilePlugins = require('./compilePlugins.js');
const os = require('os');
// disable electron security warnings: https://github.com/electron/electron/blob/master/docs/tutorial/security.md#security-native-capabilities-and-your-responsibility
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true;
if (!process.env.ANDROID_HOME) {
process.env.ANDROID_HOME = '/opt/android_sdk';
}