mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-22 18:22:41 +00:00
Avoid unnecessary work in systemd log row handling for invalid logs
Change-type: patch
This commit is contained in:
parent
b94a4f7047
commit
e3806ec018
@ -169,20 +169,25 @@ class LogMonitor {
|
|||||||
|
|
||||||
private handleRow(row: JournalRow) {
|
private handleRow(row: JournalRow) {
|
||||||
if (
|
if (
|
||||||
row.CONTAINER_ID_FULL &&
|
row.CONTAINER_ID_FULL == null ||
|
||||||
row.CONTAINER_NAME !== 'balena_supervisor' &&
|
row.CONTAINER_NAME === 'balena_supervisor' ||
|
||||||
row.CONTAINER_NAME !== 'resin_supervisor'
|
row.CONTAINER_NAME === 'resin_supervisor'
|
||||||
) {
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const containerId = row.CONTAINER_ID_FULL;
|
const containerId = row.CONTAINER_ID_FULL;
|
||||||
|
if (this.containers[containerId] == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const message = messageFieldToString(row.MESSAGE);
|
const message = messageFieldToString(row.MESSAGE);
|
||||||
|
if (message == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const isStdErr = row.PRIORITY === '3';
|
const isStdErr = row.PRIORITY === '3';
|
||||||
const timestamp = Math.floor(Number(row.__REALTIME_TIMESTAMP) / 1000); // microseconds to milliseconds
|
const timestamp = Math.floor(Number(row.__REALTIME_TIMESTAMP) / 1000); // microseconds to milliseconds
|
||||||
if (message != null && this.containers[containerId]) {
|
|
||||||
this.updateContainerSentTimestamp(containerId, timestamp);
|
this.updateContainerSentTimestamp(containerId, timestamp);
|
||||||
this.containers[containerId].hook({ message, isStdErr, timestamp });
|
this.containers[containerId].hook({ message, isStdErr, timestamp });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private updateContainerSentTimestamp(
|
private updateContainerSentTimestamp(
|
||||||
containerId: string,
|
containerId: string,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user