From 844abca78c24331b064a0f491011c0e07d5095d0 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 27 Apr 2021 01:42:52 -0700 Subject: [PATCH] Expose `logger` from `client` Summary: The `logger` was currently only available in a React context, and not directly exposed from the `client` API as well. This diff fixes it. The infrastructure including test stubs were present already, so the change is minimal. Reviewed By: nikoant Differential Revision: D28010120 fbshipit-source-id: cdd09ed236f5d92d07005d4e5a699360596281e4 --- desktop/flipper-plugin/src/plugin/PluginBase.tsx | 7 +++++++ docs/extending/flipper-plugin.mdx | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/desktop/flipper-plugin/src/plugin/PluginBase.tsx b/desktop/flipper-plugin/src/plugin/PluginBase.tsx index 1aca92c44..176731cff 100644 --- a/desktop/flipper-plugin/src/plugin/PluginBase.tsx +++ b/desktop/flipper-plugin/src/plugin/PluginBase.tsx @@ -16,6 +16,7 @@ import {Device, RealFlipperDevice} from './DevicePlugin'; import {batched} from '../state/batch'; import {Idler} from '../utils/Idler'; import {Notification} from './Notification'; +import {Logger} from '../utils/Logger'; type StateExportHandler = ( idler: Idler, @@ -91,6 +92,11 @@ export interface BasePluginClient { * Writes text to the clipboard of the Operating System */ writeTextToClipboard(text: string): void; + + /** + * Logger instance that logs information to the console, but also to the internal logging (in FB only builds) and which can be used to track performance. + */ + logger: Logger; } let currentPluginInstance: BasePluginInstance | undefined = undefined; @@ -284,6 +290,7 @@ export abstract class BasePluginInstance { showNotification: (notification: Notification) => { this.flipperLib.showNotification(this.pluginKey, notification); }, + logger: this.flipperLib.logger, }; } diff --git a/docs/extending/flipper-plugin.mdx b/docs/extending/flipper-plugin.mdx index af97d83fb..dc4c66fc6 100644 --- a/docs/extending/flipper-plugin.mdx +++ b/docs/extending/flipper-plugin.mdx @@ -332,6 +332,11 @@ The gatekeepers are cached in `localStorage`. Therefore, you might get the cache +#### `logger` + +Logger instance that logs information to the console, but also to the internal logging (in FB only builds) and which can be used to track performance. +See also [`useLogger`](#uselogger). + ## DevicePluginClient ### Properties