Introduce useLogger hook

Summary: In the Flipper chrome there is a lot of `logger={logger}` prop drilling. Let's not do that anymore in the future by using a proper hook, which is exposed from `flipper-plugin`.

Reviewed By: passy

Differential Revision: D25421304

fbshipit-source-id: 01ec8563c67f7e2fac359c2f8216eba722bff8d9
This commit is contained in:
Michel Weststrate
2020-12-09 05:31:13 -08:00
committed by Facebook GitHub Bot
parent 083dbd3dbc
commit 4aff8c1bcf
7 changed files with 130 additions and 43 deletions

View File

@@ -7,33 +7,9 @@
* @format
*/
export type LogTypes = 'error' | 'warn' | 'info' | 'debug';
export type TrackType =
| 'duration'
| 'usage'
| 'performance'
| 'success-rate'
| 'operation-cancelled';
export {LogTypes, TrackType, Logger} from 'flipper-plugin';
export type Args = {
isHeadless?: boolean;
isTest?: boolean;
};
export interface Logger {
track(type: TrackType, event: string, data?: any, plugin?: string): void;
trackTimeSince(
mark: string,
eventName?: string | null | undefined,
data?: any,
): void;
info(data: any, category: string): void;
warn(data: any, category: string): void;
error(data: any, category: string): void;
debug(data: any, category: string): void;
}