diff --git a/src/devices/AndroidDevice.js b/src/devices/AndroidDevice.js index 46c188064..24b5ac850 100644 --- a/src/devices/AndroidDevice.js +++ b/src/devices/AndroidDevice.js @@ -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 { + return child_process_promise.spawn('adb', ['logcat', '-c']); + } } diff --git a/src/devices/BaseDevice.js b/src/devices/BaseDevice.js index 3ec6b7667..253f9a095 100644 --- a/src/devices/BaseDevice.js +++ b/src/devices/BaseDevice.js @@ -123,6 +123,11 @@ export default class BaseDevice { return this.logEntries; } + clearLogs(): Promise { + // Only for device types that allow clearing. + return Promise.resolve(); + } + removeLogListener(id: Symbol) { this.logListeners.delete(id); } diff --git a/src/plugins/logs/index.js b/src/plugins/logs/index.js index bac1b1cf2..bdcca1ade 100644 --- a/src/plugins/logs/index.js +++ b/src/plugins/logs/index.js @@ -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: [],