Add a menu item to export Flipper logs to a file
Summary: CHANGELOG: Add Flipper logs export to file Allows users to export their Flipper logs with a single click. The export always includes all log levels but debug. Reviewed By: antonk52 Differential Revision: D37485571 fbshipit-source-id: 82b02132794da30b255e6178db4a17c1ba8091ee
This commit is contained in:
committed by
Facebook GitHub Bot
parent
dcbc7c40bb
commit
47956087ee
@@ -62,6 +62,7 @@ import {
|
|||||||
showOpenDialog,
|
showOpenDialog,
|
||||||
startFileExport,
|
startFileExport,
|
||||||
startLinkExport,
|
startLinkExport,
|
||||||
|
startLogsExport,
|
||||||
} from '../utils/exportData';
|
} from '../utils/exportData';
|
||||||
import {openDeeplinkDialog} from '../deeplink';
|
import {openDeeplinkDialog} from '../deeplink';
|
||||||
import {css} from '@emotion/css';
|
import {css} from '@emotion/css';
|
||||||
@@ -224,6 +225,11 @@ function ExtrasMenu() {
|
|||||||
() => startFileExport(store.dispatch),
|
() => startFileExport(store.dispatch),
|
||||||
[store.dispatch],
|
[store.dispatch],
|
||||||
);
|
);
|
||||||
|
const startLogsExportTracked = useTrackedCallback(
|
||||||
|
'Logs export',
|
||||||
|
startLogsExport,
|
||||||
|
[],
|
||||||
|
);
|
||||||
const startLinkExportTracked = useTrackedCallback(
|
const startLinkExportTracked = useTrackedCallback(
|
||||||
'Link export',
|
'Link export',
|
||||||
() => startLinkExport(store.dispatch),
|
() => startLinkExport(store.dispatch),
|
||||||
@@ -259,6 +265,11 @@ function ExtrasMenu() {
|
|||||||
key="extras"
|
key="extras"
|
||||||
title={<LeftRailButton icon={<SettingOutlined />} small />}
|
title={<LeftRailButton icon={<SettingOutlined />} small />}
|
||||||
className={submenu}>
|
className={submenu}>
|
||||||
|
{canFileExport() ? (
|
||||||
|
<Menu.Item key="exportLogs" onClick={startLogsExportTracked}>
|
||||||
|
Export Flipper logs
|
||||||
|
</Menu.Item>
|
||||||
|
) : null}
|
||||||
{canOpenDialog() ? (
|
{canOpenDialog() ? (
|
||||||
<Menu.Item key="importFlipperFile" onClick={startImportTracked}>
|
<Menu.Item key="importFlipperFile" onClick={startImportTracked}>
|
||||||
Import Flipper file
|
Import Flipper file
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import ShareSheetExportFile from '../chrome/ShareSheetExportFile';
|
|||||||
import ExportDataPluginSheet from '../chrome/ExportDataPluginSheet';
|
import ExportDataPluginSheet from '../chrome/ExportDataPluginSheet';
|
||||||
import {getRenderHostInstance} from 'flipper-frontend-core';
|
import {getRenderHostInstance} from 'flipper-frontend-core';
|
||||||
import {uploadFlipperMedia} from '../fb-stubs/user';
|
import {uploadFlipperMedia} from '../fb-stubs/user';
|
||||||
|
import {logsAtom} from '../chrome/ConsoleLogs';
|
||||||
|
|
||||||
export const IMPORT_FLIPPER_TRACE_EVENT = 'import-flipper-trace';
|
export const IMPORT_FLIPPER_TRACE_EVENT = 'import-flipper-trace';
|
||||||
export const EXPORT_FLIPPER_TRACE_EVENT = 'export-flipper-trace';
|
export const EXPORT_FLIPPER_TRACE_EVENT = 'export-flipper-trace';
|
||||||
@@ -604,6 +605,14 @@ export function canFileExport() {
|
|||||||
return !!getRenderHostInstance().showSaveDialog;
|
return !!getRenderHostInstance().showSaveDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function startLogsExport() {
|
||||||
|
const serializedLogs = logsAtom
|
||||||
|
.get()
|
||||||
|
.map((item) => JSON.stringify(item))
|
||||||
|
.join('\n');
|
||||||
|
await getRenderHostInstance().exportFile?.(serializedLogs);
|
||||||
|
}
|
||||||
|
|
||||||
export async function startFileExport(dispatch: Store['dispatch']) {
|
export async function startFileExport(dispatch: Store['dispatch']) {
|
||||||
const file = await getRenderHostInstance().showSaveDialog?.({
|
const file = await getRenderHostInstance().showSaveDialog?.({
|
||||||
title: 'FlipperExport',
|
title: 'FlipperExport',
|
||||||
|
|||||||
Reference in New Issue
Block a user