Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/candidate-9.2.x' into candidate-…
Browse files Browse the repository at this point in the history
…9.4.x

Signed-off-by: Gordon Smith <[email protected]>
  • Loading branch information
GordonSmith committed Oct 18, 2024
2 parents 1d7e188 + 4a38af6 commit 0dcdd6f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
14 changes: 12 additions & 2 deletions esp/src/src-react/components/Logs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CommandBar, ContextualMenuItemType, ICommandBarItemProps } from "@fluen
import { GetLogsExRequest, LogaccessService, LogType, TargetAudience, WsLogaccess } from "@hpcc-js/comms";
import { Level, scopedLogger } from "@hpcc-js/util";
import nlsHPCC from "src/nlsHPCC";
import { logColor, removeAllExcept, wuidToDate, wuidToTime } from "src/Utility";
import { formatDateString, logColor, removeAllExcept, timestampToDate, wuidToDate, wuidToTime } from "src/Utility";
import { useLogAccessInfo } from "../hooks/platform";
import { HolyGrail } from "../layouts/HolyGrail";
import { pushParams } from "../util/history";
Expand Down Expand Up @@ -133,7 +133,17 @@ export const Logs: React.FunctionComponent<LogsProps> = ({
}
});
const retVal = {
timestamp: { label: nlsHPCC.TimeStamp, width: 140, sortable: false, },
timestamp: {
label: nlsHPCC.TimeStamp, width: 140, sortable: false,
formatter: ts => {
if (ts) {
if (ts.indexOf(":") < 0) {
return timestampToDate(ts).toISOString();
}
return formatDateString(ts);
}
},
},
message: { label: nlsHPCC.Message, width: 600, sortable: false, },
components: { label: nlsHPCC.ContainerName, width: 150, sortable: false },
instance: { label: nlsHPCC.PodName, width: 150, sortable: false },
Expand Down
23 changes: 23 additions & 0 deletions esp/src/src/Utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,29 @@ export function format(labelTpl, obj) {
.join("\n")
;
}

const TEN_TRILLION = 10000000000000;
export function nanosToMillis(timestamp: number): number {
if (timestamp > TEN_TRILLION) {
return Math.round(timestamp / 1000000);
} else {
return timestamp;
}
}

export function timestampToDate(timestamp: number): Date {
const millis = nanosToMillis(timestamp);
return new Date(millis);
}

export function formatDateString(dateStr: string): string {
const matches = dateStr.match(/([0-9]{4}(?:-[0-9]{1,2})+)([T\s])((?:[0-9]{1,2}:)+[0-9]{1,2}\.[0-9]{1,3})(Z*)/);
if (matches) {
return `${matches[1]}T${matches[3]}${matches[4] ? matches[4] : "Z"}`;
}
return dateStr;
}

const theme = getTheme();
const { semanticColors } = theme;

Expand Down

0 comments on commit 0dcdd6f

Please sign in to comment.