Clear adb logcat when clearing Flipper logs

Summary: When using "Clear logs" in Flipper, also flush the native Android buffer.

Reviewed By: jknoxville

Differential Revision: D14225722

fbshipit-source-id: f41ff9013b95fc3271d3ae44910da18023708d2d
This commit is contained in:
Pascal Hartig
2019-02-26 16:24:07 -08:00
committed by Facebook Github Bot
parent ea03aa36b7
commit edbe2555fc
3 changed files with 13 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import type {DeviceType, DeviceShell} from './BaseDevice.js';
import {Priority} from 'adbkit-logcat-fb';
import child_process from 'child_process';
import child_process_promise from 'child-process-es6-promise';
import BaseDevice from './BaseDevice.js';
type ADBClient = any;
@@ -80,4 +81,8 @@ export default class AndroidDevice extends BaseDevice {
spawnShell(): ?DeviceShell {
return child_process.spawn('adb', ['-s', this.serial, 'shell', '-t', '-t']);
}
clearLogs(): Promise<void> {
return child_process_promise.spawn('adb', ['logcat', '-c']);
}
}

View File

@@ -123,6 +123,11 @@ export default class BaseDevice {
return this.logEntries;
}
clearLogs(): Promise<void> {
// Only for device types that allow clearing.
return Promise.resolve();
}
removeLogListener(id: Symbol) {
this.logListeners.delete(id);
}

View File

@@ -522,6 +522,9 @@ export default class LogTable extends FlipperDevicePlugin<
}
clearLogs = () => {
this.device.clearLogs().catch(e => {
console.error('Failed to clear logs: ', e);
});
this.setState({
entries: [],
rows: [],