[~] splitOut timestamp

Signed-off-by: Arthur Knoepflin <arthur@knoepflin.eu>
This commit is contained in:
Arthur Knoepflin committed 2021-04-19 23:02:29 +02:00
1 parent 6dc756bad0
commit 0c121b7086
2 files changed
+13 -3

No files matched your search

+3 -3
View File
@@ -87,9 +87,9 @@ export class LogList extends React.Component<Props> {
return logStore.logsWithoutTimestamps;
}
return this.props.logs.map(log => (
`${moment.tz(logStore.getTimestamps(log)[0] || "", preferences.localeTimezone).format()} ${logStore.removeTimestamps(log)}`
));
return this.props.logs
.map(log => logStore.splitOutTimestamp(log))
.map(([logTimestamp, log]) => (`${moment.tz(logTimestamp, preferences.localeTimezone).format()} ${log}`));
}
/**
+10
View File
@@ -146,6 +146,16 @@ export class LogStore {
return stamp.toISOString();
}
splitOutTimestamp(logs: string): [string, string] {
const extraction = /^(\d+\S+) (.*)/gm.exec(logs);
if (extraction.length < 3) {
return ["", ""];
}
return [extraction[1], extraction[2]];
}
getTimestamps(logs: string) {
return logs.match(/^\d+\S+/gm);
}