Avoid unnecessary work in systemd log row handling for invalid logs

Change-type: patch
This commit is contained in:
Pagan Gazzard 2023-10-11 14:07:17 +01:00 committed by Felipe Lalanne
parent b94a4f7047
commit e3806ec018

View File

@ -169,20 +169,25 @@ class LogMonitor {
private handleRow(row: JournalRow) {
if (
row.CONTAINER_ID_FULL &&
row.CONTAINER_NAME !== 'balena_supervisor' &&
row.CONTAINER_NAME !== 'resin_supervisor'
row.CONTAINER_ID_FULL == null ||
row.CONTAINER_NAME === 'balena_supervisor' ||
row.CONTAINER_NAME === 'resin_supervisor'
) {
return;
}
const containerId = row.CONTAINER_ID_FULL;
if (this.containers[containerId] == null) {
return;
}
const message = messageFieldToString(row.MESSAGE);
if (message == null) {
return;
}
const isStdErr = row.PRIORITY === '3';
const timestamp = Math.floor(Number(row.__REALTIME_TIMESTAMP) / 1000); // microseconds to milliseconds
if (message != null && this.containers[containerId]) {
this.updateContainerSentTimestamp(containerId, timestamp);
this.containers[containerId].hook({ message, isStdErr, timestamp });
}
}
}
private updateContainerSentTimestamp(
containerId: string,