Use journalctl --utc for Logs view to handle DST

This commit is contained in:
Justin Stephenson 2020-11-04 13:58:29 -05:00
parent 819da4d495
commit e504489ab0

View file

@ -88,11 +88,6 @@ const formatDateTime = function (ms) {
return moment(ms).format("YYYY-MM-DD HH:mm:ss"); return moment(ms).format("YYYY-MM-DD HH:mm:ss");
}; };
const formatDateTimeOffset = function (ms, offset) {
return moment(ms).utcOffset(offset)
.format("YYYY-MM-DD HH:mm:ss");
};
const formatUTC = function(date) { const formatUTC = function(date) {
return moment(date).utc() return moment(date).utc()
.format("YYYY-MM-DD HH:mm:ss") + " UTC"; .format("YYYY-MM-DD HH:mm:ss") + " UTC";
@ -188,7 +183,6 @@ class Logs extends React.Component {
this.getLogs = this.getLogs.bind(this); this.getLogs = this.getLogs.bind(this);
this.loadLater = this.loadLater.bind(this); this.loadLater = this.loadLater.bind(this);
this.loadForTs = this.loadForTs.bind(this); this.loadForTs = this.loadForTs.bind(this);
this.getServerTimeOffset = this.getServerTimeOffset.bind(this);
this.journalCtl = null; this.journalCtl = null;
this.entries = []; this.entries = [];
this.start = null; this.start = null;
@ -202,16 +196,6 @@ class Logs extends React.Component {
}; };
} }
getServerTimeOffset() {
cockpit.spawn(["date", "+%s:%:z"], { err: "message" })
.done((data) => {
this.setState({ serverTimeOffset: data.slice(data.indexOf(":") + 1) });
})
.fail((ex) => {
console.log("Couldn't calculate server time offset: " + cockpit.message(ex));
});
}
journalctlError(error) { journalctlError(error) {
console.warn(cockpit.message(error)); console.warn(cockpit.message(error));
} }
@ -244,13 +228,8 @@ class Logs extends React.Component {
let start = null; let start = null;
let end = null; let end = null;
if (this.state.serverTimeOffset != null) { start = formatDateTime(this.start);
start = formatDateTimeOffset(this.start, this.state.serverTimeOffset); end = formatDateTime(this.end);
end = formatDateTimeOffset(this.end, this.state.serverTimeOffset);
} else {
start = formatDateTime(this.start);
end = formatDateTime(this.end);
}
const options = { const options = {
since: start, since: start,
@ -258,6 +237,7 @@ class Logs extends React.Component {
follow: false, follow: false,
count: "all", count: "all",
merge: true, merge: true,
utc: true,
}; };
if (this.state.after != null) { if (this.state.after != null) {
@ -285,10 +265,6 @@ class Logs extends React.Component {
this.getLogs(); this.getLogs();
} }
componentDidMount() {
this.getServerTimeOffset();
}
componentDidUpdate() { componentDidUpdate() {
if (this.props.recording) { if (this.props.recording) {
if (this.start === null && this.end === null) { if (this.start === null && this.end === null) {