Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(logs): add view settings menu to the logs viewer toolbar (#69252)

Jon McCallum8fde83e00d4b
diff --git a/products/logs/frontend/components/LogsViewer/LogsViewSettings.tsx b/products/logs/frontend/components/LogsViewer/LogsViewSettings.tsx
new file mode 100644
index 000000000000..afd01d34b795
--- /dev/null
+++ b/products/logs/frontend/components/LogsViewer/LogsViewSettings.tsx
@@ -0,0 +1,54 @@
+import { useActions, useValues } from 'kea'
+import { useState } from 'react'
+
+import { IconEye } from '@posthog/icons'
+import { LemonButton, LemonSwitch } from '@posthog/lemon-ui'
+
+import { TimezoneSelect } from 'lib/components/TimezoneSelect'
+import { Popover } from 'lib/lemon-ui/Popover'
+
+import { logsViewerSettingsLogic } from './logsViewerSettingsLogic'
+
+/**
+ * Display settings for the logs list — wrap + timezone. Timezone is shared state with the
+ * date range picker's timezone control (logsViewerSettingsLogic); both surfaces write it.
+ */
+export const LogsViewSettings = (): JSX.Element => {
+ const [isOpen, setIsOpen] = useState(false)
+ const { wrapBody, timezone } = useValues(logsViewerSettingsLogic)
+ const { setWrapBody, setTimezone } = useActions(logsViewerSettingsLogic)
+
+ return (
+ <Popover
+ visible={isOpen}
+ onClickOutside={() => setIsOpen(false)}
+ placement="bottom-end"
+ overlay={
+ <div className="p-2 w-72 flex flex-col gap-2">
+ <LemonSwitch
+ checked={wrapBody}
+ onChange={setWrapBody}
+ label="Wrap log lines"
+ size="small"
+ fullWidth
+ bordered
+ />
+ <div className="flex items-center justify-between gap-2">
+ <span className="text-sm">Timezone display</span>
+ <TimezoneSelect value={timezone} onChange={setTimezone} size="small" />
+ </div>
+ </div>
+ }
+ >
+ <LemonButton
+ size="small"
+ type="secondary"
+ icon={<IconEye />}
+ onClick={() => setIsOpen(!isOpen)}
+ tooltip="View settings"
+ aria-label="View settings"
+ data-attr="logs-view-settings"
+ />
+ </Popover>
+ )
+}
diff --git a/products/logs/frontend/components/LogsViewer/LogsViewerToolbar.tsx b/products/logs/frontend/components/LogsViewer/LogsViewerToolbar.tsx
index 5569f9f5674a..28cca7257b38 100644
--- a/products/logs/frontend/components/LogsViewer/LogsViewerToolbar.tsx
+++ b/products/logs/frontend/components/LogsViewer/LogsViewerToolbar.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues } from 'kea'
import { IconKeyboard } from '@posthog/icons'
-import { LemonButton, LemonCheckbox, Tooltip } from '@posthog/lemon-ui'
+import { LemonButton, Tooltip } from '@posthog/lemon-ui'
import { Shortcut } from 'lib/components/Shortcuts/Shortcut'
import { keyBinds } from 'lib/components/Shortcuts/shortcuts'
@@ -13,7 +13,7 @@ import { KeyboardShortcut } from '~/layout/navigation-3000/components/KeyboardSh
import { logsViewerDataLogic } from 'products/logs/frontend/components/LogsViewer/data/logsViewerDataLogic'
import { LogsExportMenu } from './LogsExportMenu'
-import { logsViewerLogic } from './logsViewerLogic'
+import { LogsViewSettings } from './LogsViewSettings'
export interface LogsViewerToolbarProps {
// Used by the export menu for its "all matching logs" label + size limit, not shown as a count here
@@ -22,16 +22,15 @@ export interface LogsViewerToolbarProps {
}
/**
- * Contextual-right cluster of the results bar — live tail, the wrap-message toggle, export and the
- * keyboard-shortcut help. Logs-only: the bar hides this whole cluster in Patterns mode, where none of
- * it applies. Sort order is driven by the timestamp-column arrow and timezone by the date range picker,
- * so neither has a control here. Live tail streams the query (the others don't re-run it) — it lives
+ * Contextual-right cluster of the results bar — live tail, view settings (wrap + timezone display),
+ * export and the keyboard-shortcut help. Logs-only: the bar hides this whole cluster in Patterns mode,
+ * where none of it applies. Sort order is driven by the timestamp-column arrow, so it has no control
+ * here. Timezone is editable both in view settings and in the date range picker — both write the same
+ * logsViewerSettingsLogic state. Live tail streams the query (the others don't re-run it) — it lives
* here, technically the "wrong" scope, so it hides with this cluster instead of shifting the top bar's
* layout when the lens changes.
*/
export const LogsViewerToolbar = ({ totalLogsCount }: LogsViewerToolbarProps): JSX.Element => {
- const { wrapBody } = useValues(logsViewerLogic)
- const { setWrapBody } = useActions(logsViewerLogic)
const { liveTailRunning, liveTailDisabledReason } = useValues(logsViewerDataLogic)
const { setLiveTailRunning } = useActions(logsViewerDataLogic)
@@ -54,7 +53,7 @@ export const LogsViewerToolbar = ({ totalLogsCount }: LogsViewerToolbarProps): J
Live tail
</LemonButton>
</Shortcut>
- <LemonCheckbox checked={wrapBody} bordered onChange={setWrapBody} label="Wrap message" size="small" />
+ <LogsViewSettings />
<LogsExportMenu totalLogsCount={totalLogsCount} />
<Tooltip
title={