Files
flipper/src/fb-stubs/Logger.js
John Knox 77811c66d2 Add reportPluginFailures in client.call method
Summary:
Adds an optional "plugin" field to the tracked metrics. The idea is to be able to see failures in plugins.

Added it around all desktop -> sdk "call"s, so it won't require any effort from developers but we'll get lots of immediate data. E.g. How often layout -> getNodes fails. I think we can go modify the existing pipeline to take both platform and plugin data so we can get session roll-ups too.

Corresponding change to the puma app: D13882629, adds a plugin field to all tables so we can filter by plugin, or null for platform failures.

I'm thinking it will be worthwhile to expose some method to plugin developers, that lets them explicitly track failures. It would be better if it encapsulated their plugin id etc, so they just need to say what failed. But that can be done any time, I don't have any particular use cases in mind yet.

Reviewed By: passy

Differential Revision: D13878379

fbshipit-source-id: 2e2ef6b98f763e6edcfe937741d6988dae4b92d1
2019-01-31 03:23:41 -08:00

50 lines
1.2 KiB
JavaScript

/**
* Copyright 2018-present Facebook.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* @format
*/
export type LogTypes = 'error' | 'warn' | 'info' | 'debug';
export type TrackType = 'duration' | 'usage' | 'performance' | 'success-rate';
import ScribeLogger from './ScribeLogger';
var instance: ?LogManager = null;
export default class LogManager {
constructor(store: Store) {
this.scribeLogger = new ScribeLogger(this);
}
scribeLogger: ScribeLogger;
track(type: TrackType, event: string, data: ?any, plugin?: string) {}
trackTimeSince(mark: string, eventName: ?string) {}
info(data: any, category: string) {}
warn(data: any, category: string) {}
error(data: any, category: string) {}
debug(data: any, category: string) {}
}
export function init(store: Store): LogManager {
if (instance) {
throw new Error('Attempted to initialize Logger when already initialized');
}
instance = new LogManager(store);
return instance;
}
export function getInstance(): LogManager {
if (!instance) {
throw new Error(
'Requested Logger instance without initializing it. Make sure init() is called at app start',
);
}
return instance;
}