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:
Daniel Büchele
2019-02-20 06:39:39 -08:00
committed by Facebook Github Bot
parent d8d01b4a6f
commit 6c0a534e15
3 changed files with 34 additions and 31 deletions

View File

@@ -25,35 +25,34 @@ export default class AndroidDevice extends BaseDevice {
this.adb.openLogcat(this.serial).then(reader => {
reader.on('entry', entry => {
if (this.logListeners.size > 0) {
let type = 'unknown';
if (entry.priority === Priority.VERBOSE) {
type = 'verbose';
}
if (entry.priority === Priority.DEBUG) {
type = 'debug';
}
if (entry.priority === Priority.INFO) {
type = 'info';
}
if (entry.priority === Priority.WARN) {
type = 'warn';
}
if (entry.priority === Priority.ERROR) {
type = 'error';
}
if (entry.priority === Priority.FATAL) {
type = 'fatal';
}
this.notifyLogListeners({
tag: entry.tag,
pid: entry.pid,
tid: entry.tid,
message: entry.message,
date: entry.date,
type,
});
let type = 'unknown';
if (entry.priority === Priority.VERBOSE) {
type = 'verbose';
}
if (entry.priority === Priority.DEBUG) {
type = 'debug';
}
if (entry.priority === Priority.INFO) {
type = 'info';
}
if (entry.priority === Priority.WARN) {
type = 'warn';
}
if (entry.priority === Priority.ERROR) {
type = 'error';
}
if (entry.priority === Priority.FATAL) {
type = 'fatal';
}
this.addLogEntry({
tag: entry.tag,
pid: entry.pid,
tid: entry.tid,
message: entry.message,
date: entry.date,
type,
});
});
});
}

View File

@@ -101,8 +101,7 @@ export default class BaseDevice {
return id;
}
notifyLogListeners(entry: DeviceLogEntry) {
this.logEntries.push(entry);
_notifyLogListeners(entry: DeviceLogEntry) {
if (this.logListeners.size > 0) {
this.logListeners.forEach(listener => {
// 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() {
return this.logEntries;
}

View File

@@ -105,7 +105,7 @@ export default class IOSDevice extends BaseDevice {
.pipe(JSONStream.parse('*'))
.on('data', (data: RawLogEntry) => {
const entry = IOSDevice.parseLogEntry(data);
this.notifyLogListeners(entry);
this.addLogEntry(entry);
});
} catch (e) {
console.error('Could not parse iOS log stream.', e);