Cope with multiline logs

This commit is contained in:
Richard Bowman 2024-01-08 11:53:37 +00:00
parent a53062af83
commit 24060b6d2a
2 changed files with 17 additions and 7 deletions

View file

@ -86,7 +86,7 @@ export default {
this.modalNotify(`Background image has been updated`);
},
alertImageLabel(r) {
let label = r.output===true? 'sample' : 'background'
let label = r.output === true ? "sample" : "background";
this.modalNotify(`Current image is ${label}`);
}
}

View file

@ -141,12 +141,22 @@ export default {
for (let line of lines) {
if (line.length > 0) {
let m = line.match(regexp);
this.logs.push({
timestamp: m[1],
level: m[2],
message: m[3],
sequence: this.logs.length
});
if (m) {
this.logs.push({
timestamp: m[1],
level: m[2],
message: m[3],
sequence: this.logs.length
});
} else if (this.logs) {
// If a line does not look like a log entry, append it to the last
// log entry (i.e. allow multi-line messages)
this.logs[this.logs.length - 1].message += "\n" + line;
} else {
// if there's no existing log message to append to, discard lines
// until we find one.
continue;
}
}
}
},