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
This commit is contained in:
Michel Weststrate
2021-04-27 01:42:52 -07:00
committed by Facebook GitHub Bot
parent c89d18fd68
commit 844abca78c
2 changed files with 12 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ import {Device, RealFlipperDevice} from './DevicePlugin';
import {batched} from '../state/batch'; import {batched} from '../state/batch';
import {Idler} from '../utils/Idler'; import {Idler} from '../utils/Idler';
import {Notification} from './Notification'; import {Notification} from './Notification';
import {Logger} from '../utils/Logger';
type StateExportHandler<T = any> = ( type StateExportHandler<T = any> = (
idler: Idler, idler: Idler,
@@ -91,6 +92,11 @@ export interface BasePluginClient {
* Writes text to the clipboard of the Operating System * Writes text to the clipboard of the Operating System
*/ */
writeTextToClipboard(text: string): void; 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; let currentPluginInstance: BasePluginInstance | undefined = undefined;
@@ -284,6 +290,7 @@ export abstract class BasePluginInstance {
showNotification: (notification: Notification) => { showNotification: (notification: Notification) => {
this.flipperLib.showNotification(this.pluginKey, notification); this.flipperLib.showNotification(this.pluginKey, notification);
}, },
logger: this.flipperLib.logger,
}; };
} }

View File

@@ -332,6 +332,11 @@ The gatekeepers are cached in `localStorage`. Therefore, you might get the cache
</FbInternalOnly> </FbInternalOnly>
#### `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 ## DevicePluginClient
### Properties ### Properties