fix logs
Summary:
Logs were not collected in headless mode, because there was no subscriber listening to the logs. Now they are always stored, even if there is no subscriber. Actually this makes more sense even for the desktop UI, as subscribers could subscribe later.
The only reason this was working on the desktop app was because the log plugin automatically subscribed on launch.
This brings us to the actual question: If a message is logged in a forest and no one is around to read it, is it actually logged? 🤯
Reviewed By: passy
Differential Revision: D14149691
fbshipit-source-id: 212f1b0a69bd0cc8ae0ba3592f29ca90b7a5a475
This commit is contained in:
committed by
Facebook Github Bot
parent
d8d01b4a6f
commit
6c0a534e15
@@ -25,7 +25,6 @@ export default class AndroidDevice extends BaseDevice {
|
|||||||
|
|
||||||
this.adb.openLogcat(this.serial).then(reader => {
|
this.adb.openLogcat(this.serial).then(reader => {
|
||||||
reader.on('entry', entry => {
|
reader.on('entry', entry => {
|
||||||
if (this.logListeners.size > 0) {
|
|
||||||
let type = 'unknown';
|
let type = 'unknown';
|
||||||
if (entry.priority === Priority.VERBOSE) {
|
if (entry.priority === Priority.VERBOSE) {
|
||||||
type = 'verbose';
|
type = 'verbose';
|
||||||
@@ -45,7 +44,8 @@ export default class AndroidDevice extends BaseDevice {
|
|||||||
if (entry.priority === Priority.FATAL) {
|
if (entry.priority === Priority.FATAL) {
|
||||||
type = 'fatal';
|
type = 'fatal';
|
||||||
}
|
}
|
||||||
this.notifyLogListeners({
|
|
||||||
|
this.addLogEntry({
|
||||||
tag: entry.tag,
|
tag: entry.tag,
|
||||||
pid: entry.pid,
|
pid: entry.pid,
|
||||||
tid: entry.tid,
|
tid: entry.tid,
|
||||||
@@ -53,7 +53,6 @@ export default class AndroidDevice extends BaseDevice {
|
|||||||
date: entry.date,
|
date: entry.date,
|
||||||
type,
|
type,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,8 +101,7 @@ export default class BaseDevice {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyLogListeners(entry: DeviceLogEntry) {
|
_notifyLogListeners(entry: DeviceLogEntry) {
|
||||||
this.logEntries.push(entry);
|
|
||||||
if (this.logListeners.size > 0) {
|
if (this.logListeners.size > 0) {
|
||||||
this.logListeners.forEach(listener => {
|
this.logListeners.forEach(listener => {
|
||||||
// prevent breaking other listeners, if one listener doesn't work.
|
// prevent breaking other listeners, if one listener doesn't work.
|
||||||
@@ -115,6 +114,11 @@ export default class BaseDevice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addLogEntry(entry: DeviceLogEntry) {
|
||||||
|
this.logEntries.push(entry);
|
||||||
|
this._notifyLogListeners(entry);
|
||||||
|
}
|
||||||
|
|
||||||
getLogs() {
|
getLogs() {
|
||||||
return this.logEntries;
|
return this.logEntries;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ export default class IOSDevice extends BaseDevice {
|
|||||||
.pipe(JSONStream.parse('*'))
|
.pipe(JSONStream.parse('*'))
|
||||||
.on('data', (data: RawLogEntry) => {
|
.on('data', (data: RawLogEntry) => {
|
||||||
const entry = IOSDevice.parseLogEntry(data);
|
const entry = IOSDevice.parseLogEntry(data);
|
||||||
this.notifyLogListeners(entry);
|
this.addLogEntry(entry);
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Could not parse iOS log stream.', e);
|
console.error('Could not parse iOS log stream.', e);
|
||||||
|
|||||||
Reference in New Issue
Block a user