import { Formatter, FormatterConfig, PredefinedFormatters } from "./formatters"; import { LogEntry, NotifyCallback, PredefinedSpies, Spy, SpyConfig } from "./spies"; import { PredefinedStorages, Storage, StorageConfig } from "./storages"; import { PredefinedTransports, Transport, TransportConfig } from "./transports"; /** * @category Log Manager * @interface Log.LogManagerConfig * @property {string} [identifier] a unique name of the log manager that prevents collected data from overlapping with other log managers * @property {Array} spies an array of configurations for predefined spies or factories for custom spies * @property {Log.StorageConfig} storage a configuration for predefined storage or a factory for custom storage * @property {Log.FormatterConfig} formatter a configuration for predefined formatter or a factory for custom formatter * @property {Log.TransportConfig} transport a configuration for predefined transport or a factory for custom transport * @private */ export interface LogManagerConfig { identifier?: string; spies: Array; storage?: StorageConfig; transport?: TransportConfig; formatter?: FormatterConfig; } /** * Log manager is dedicated to collect logs across Flex ecosystem by abstracting the process * of gathering data into multiple stages, that can be customized to match specific use cases. * Log manager has following modules: *
  • {@link Log.Spy Spies} *
  • {@link Log.Storage Storage} – optional, the data will be passed straight to a formatter and then to a transport if a storage is falsy. By default is set to {@link Log.PredefinedStorages PredefinedStorages.LocalStorage}. *
  • {@link Log.Formatter Formatter} - by default is set to {@link Log.PredefinedFormatters PredefinedFormatters.String}. *
  • {@link Log.Transport Transport} - by default is set to {@link Log.PredefinedTransports PredefinedTransports.File}. * @private * @category Log Manager * @class Log.LogManager * @hideconstructor * @example Dublicate window.console calls to Rollbar (implying Rollbar is installed according to https://docs.rollbar.com/docs/browser-js) * const myLogManager = new Flex.Log.LogManager({ * spies: [ * // Proxy `window.console` to collect data regarding invoking it's methods * { * type: Flex.Log.PredefinedSpies.ClassProxy, * target: window.console, * targetAlias: "Proxied window.console", * methods: ["trace", "info", "log", "debug", "warn", "error"], * onStart: (proxy) => { * window.console = proxy; * } * } * ], * storage: () => null, // Don't keep logs in the storage and pass them forward immediately * formatter: () => (entries) => entries[0], // Extract the single log entry and pass it to transport * transport: () => ({ // Pass the collected intel to Rollbar, respecting the invoked method * flush: function(entry) { * const collectedData = entry && entry.subject && entry.args; * * if (!collectedData) { * return; * } * * const args = entry.args.join(); * const isRollbarMethod = typeof Rollbar[entry.subject] === "function"; * * if (isRollbarMethod) { * Rollbar[entry.subject](args); * } else { * Rollbar.log(args); * } * } * }) * }); * * myLogManager.prepare().then(myLogManager.start); */ declare class LogManager { static persistKey: string; static defaults: LogManagerConfig; private spies; private storage?; private transport; private formatter; private config; constructor(options: LogManagerConfig); /** * Start a log manager and all of it's modules. Invoke spies `start` methods. * Only takes effect if `prepare` method's promise has resolved. * @name start * @function * @returns {void} * @instance * @memberof Log.LogManager * @private */ start(): void; /** * Stop a log manager and all of it's modules. Invokes `stop` method of all spies. * Clear the prepare state of a log manager, so it will have to be prepared for a next call of `start` method. * @name stop * @function * @returns {void} * @instance * @memberof Log.LogManager * @private */ stop(): void; /** * Retrieve the collected data. * @name flush * @function * @returns {unknown} * @instance * @memberof Log.LogManager * @private */ flush(data?: LogEntry[]): T; /** * Indicate whenever a log manager is ready to be started or not * @name isReady * @function * @returns {boolean} * @instance * @memberof Log.LogManager * @private */ isReady(): boolean; /** * Indicate whenever a log manager is started and is gathering logs * @name isLogging * @function * @returns {boolean} * @instance * @memberof Log.LogManager * @private */ isLogging(): boolean; /** * Returns a snapshot with the current logs * @name getLogsSnapshot * @function * @returns {Array} * @instance * @memberof Log.LogManager * @private */ getLogsSnapshot(): LogEntry[]; /** * Run necessary preparations so that a log manager can be started * @name prepare * @function * @returns {Promise} * @instance * @memberof Log.LogManager * @private */ prepare(): Promise; private setState; private getState; } export { LogManager, NotifyCallback, Spy, Storage, Formatter, Transport, PredefinedSpies, PredefinedStorages, PredefinedFormatters, PredefinedTransports };