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:
Andrey Goncharov
2022-06-28 06:27:43 -07:00
committed by Facebook GitHub Bot
parent dcbc7c40bb
commit 47956087ee
2 changed files with 20 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ import ShareSheetExportFile from '../chrome/ShareSheetExportFile';
import ExportDataPluginSheet from '../chrome/ExportDataPluginSheet';
import {getRenderHostInstance} from 'flipper-frontend-core';
import {uploadFlipperMedia} from '../fb-stubs/user';
import {logsAtom} from '../chrome/ConsoleLogs';
export const IMPORT_FLIPPER_TRACE_EVENT = 'import-flipper-trace';
export const EXPORT_FLIPPER_TRACE_EVENT = 'export-flipper-trace';
@@ -604,6 +605,14 @@ export function canFileExport() {
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']) {
const file = await getRenderHostInstance().showSaveDialog?.({
title: 'FlipperExport',