Fixed issue with reseting logs
Summary: Noticed that subsequent `adb logcat` invocations are stateful, and we didn't clear it's state when clearing the logs in memory. This is a bandaid to get back to the previous behavior. I am wondering whether it wouldn't be just much more intuitive to always clear the logs (`adb logcat -c`) before we start the streaming log listener, so that users are never shown old logs from before flipper was connected? Also fixed a leak in cleaning up the log listeners that was revealed by the possibility to disable the log plugin Reviewed By: nikoant Differential Revision: D26450262 fbshipit-source-id: 5b426e2d0e1fafdbc512d48d22b7bd4f30b61309
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d50c253159
commit
d37f1c282a
@@ -115,6 +115,7 @@ export abstract class BasePluginInstance {
|
||||
importHandler?: StateImportHandler;
|
||||
|
||||
menuEntries: NormalizedMenuEntry[] = [];
|
||||
logListeners: Symbol[] = [];
|
||||
|
||||
constructor(
|
||||
flipperLib: FlipperLib,
|
||||
@@ -139,9 +140,9 @@ export abstract class BasePluginInstance {
|
||||
return realDevice.connected.get();
|
||||
},
|
||||
deviceType: realDevice.deviceType,
|
||||
|
||||
onLogEntry(cb) {
|
||||
onLogEntry: (cb) => {
|
||||
const handle = realDevice.addLogListener(cb);
|
||||
this.logListeners.push(handle);
|
||||
return () => {
|
||||
realDevice.removeLogListener(handle);
|
||||
};
|
||||
@@ -265,6 +266,9 @@ export abstract class BasePluginInstance {
|
||||
destroy() {
|
||||
this.assertNotDestroyed();
|
||||
this.deactivate();
|
||||
this.logListeners.splice(0).forEach((handle) => {
|
||||
this.device.realDevice.removeLogListener(handle);
|
||||
});
|
||||
this.events.emit('destroy');
|
||||
this.destroyed = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user