Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
EVG-20019: set log message timezone to user timezone and fix format (#…
Browse files Browse the repository at this point in the history
…2030)

Co-authored-by: julianedwards <[email protected]>
  • Loading branch information
julianedwards and julianedwards authored Sep 11, 2023
1 parent e73e8ad commit 2d67b79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export { useTaskStatuses } from "./useTaskStatuses";
export { useUpsertQueryParams } from "./useUpsertQueryParams";
export { useSpruceConfig } from "./useSpruceConfig";
export { useUserSettings } from "./useUserSettings";
export { useUserTimeZone } from "./useUserTimeZone";
export { useDateFormat } from "./useDateFormat";
export { useBreadcrumbRoot } from "./useBreadcrumbRoot";
export { useResize } from "./useResize";
12 changes: 9 additions & 3 deletions src/pages/task/taskTabs/logs/logTypes/LogMessageLine.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import { useMemo } from "react";
import AnsiUp from "ansi_up";
import { format } from "date-fns";
import { format, utcToZonedTime } from "date-fns-tz";
import parse from "html-react-parser";
import linkifyHtml from "linkify-html";
import { LogMessageFragment } from "gql/generated/types";
import { useUserTimeZone } from "hooks";
import { getLogLineWrapper } from "./logMessageLine/LogLines";

const FORMAT_STR = "yyyy/MM/d, HH:mm:ss.SSS";
const FORMAT_STR = "yyyy/MM/dd HH:mm:ss.SSS";
const ansiUp = new AnsiUp();

export const LogMessageLine: React.FC<LogMessageFragment> = ({
message,
severity,
timestamp,
}) => {
const time = timestamp ? `[${format(new Date(timestamp), FORMAT_STR)}] ` : "";
const tz = useUserTimeZone();
const time = timestamp
? `[${format(new Date(utcToZonedTime(timestamp, tz)), FORMAT_STR, {
timeZone: tz,
})}] `
: "";
const LogLineWrapper = getLogLineWrapper(severity);
const memoizedLogLine = useMemo(() => {
const render = linkifyHtml(ansiUp.ansi_to_html(message), {
Expand Down

0 comments on commit 2d67b79

Please sign in to comment.