interface IDestructable { /** * Clean all timeouts, intervals and links to other objects in this method */ destroy(): void; } interface IService extends IDestructable { /** * Implement direct communication with API or SDK */ sendAllLogs(logs: T[]): Promise; /** * Implement the final processing of logs before sending it directly to the endpoint */ preparePayload(logs: T[]): Promise; serializer(log: T): any; } type Listener = (...args: any[]) => void; declare class EventEmitter { private listeners; on(event: string, fn: Listener): this; once(event: string, fn: Listener): this; off(event: string, fn: Listener): this; removeListener(event: string, fn: Listener): this; emit(event: string, ...args: any[]): boolean; removeAllListeners(event?: string): this; private set; } interface IAddEventConfig { logCount: number; } interface IStrategy extends IDestructable { eventEmitter: EventEmitter; onAdd(info?: IAddEventConfig): void; onClear(): void; sendAll(): void; } declare enum TransformationEnum { RAPID_FIRE_GROUPING = 0 } interface IGroupTransformation { groupIdentityFields: string[]; groupFieldName: string; interval: number; } interface ITransformation { type: TransformationEnum; configuration: IGroupTransformation; } interface ILoggerConfig { service: IService; strategy: IStrategy; transformations?: ITransformation[]; } interface IDefaultLogConfig { [key: string]: any; } /** * Uses different strategies to submit logs to log server via Service facade. */ declare class AdvancedLogger { private configuration; private strategy; private service; private logStore; constructor(configuration: ILoggerConfig); log(log: T): void; /** * Forces strategy to initiate logs sending */ sendAllLogs(): void; destroy(): void; private onStoreError; private onAdd; private onClear; private onStrategyError; private onSend; } type Method = "GET" | "DELETE" | "HEAD" | "OPTIONS" | "POST" | "PUT" | "PATCH" | "get" | "delete" | "head" | "options" | "post" | "put" | "patch"; interface IRequestConfig { url: string; method: Method; retryInterval?: number; retryAttempts?: number; logMetaIndexField?: string; [propName: string]: any; } interface IServiceConfig { serviceConfig: IRequestConfig; defaultLogConfig?: IDefaultLogConfig; serializer?(log: T): string; } declare class BaseRemoteService implements IService, IDestructable { protected serviceConfig: IRequestConfig; protected defaultLogConfig: IDefaultLogConfig; constructor(config: IServiceConfig); serializer(log: T): string; sendAllLogs(logs: T[]): Promise; preparePayload(logs: T[]): Promise; destroy(): void; /** * Returns object for headers config * @example * {"Content-Type": "text/plain"} */ protected getHeaders(): { [propName: string]: string; }; } /** * Console reporting service for debugging purposes */ declare class ConsoleService implements IService { preparePayload(logs: T[]): Promise; sendAllLogs(logs: T[]): Promise; destroy(): void; serializer(log: T): T; } declare class ElasticsearchService extends BaseRemoteService { preparePayload(logs: T[]): Promise; protected getHeaders(): { [propName: string]: string; }; private getLogMetaConfig; } declare class LogglyService extends BaseRemoteService { protected getHeaders(): { [propName: string]: string; }; } declare class SumologicService extends BaseRemoteService { protected getHeaders(): { [propName: string]: string; }; } declare class InstantStrategy implements IStrategy { eventEmitter: EventEmitter; constructor(); onAdd(info?: IAddEventConfig): void; onClear(): void; sendAll(): void; destroy(): void; } declare class OnBundleSizeStrategy implements IStrategy { eventEmitter: EventEmitter; /** * @type {number} */ MAX_BUNDLE_SIZE: number; constructor(config: { maxBundle?: number; }); onAdd(info: IAddEventConfig): void; onClear(): void; sendAll(): void; destroy(): void; } declare class OnIntervalStrategy implements IStrategy { eventEmitter: EventEmitter; SEND_INTERVAL: number; private readonly intervalSend; constructor(config: { interval?: number; }); onAdd(info?: IAddEventConfig): void; onClear(): void; sendAll(): void; destroy(): void; private send; } declare class OnRequestStrategy implements IStrategy { eventEmitter: EventEmitter; constructor(); onAdd(info?: IAddEventConfig): void; onClear(): void; sendAll(): void; destroy(): void; } declare class HybridStrategy implements IStrategy { eventEmitter: EventEmitter; MAX_BUNDLE_SIZE: number; SEND_INTERVAL: number; private readonly intervalSend; constructor(config?: { maxBundle?: number; interval?: number; }); onAdd(info?: IAddEventConfig): void; onClear(): void; sendAll(): void; destroy(): void; private send; } declare const strategy: { InstantStrategy: typeof InstantStrategy; OnBundleSizeStrategy: typeof OnBundleSizeStrategy; OnRequestStrategy: typeof OnRequestStrategy; OnIntervalStrategy: typeof OnIntervalStrategy; HybridStrategy: typeof HybridStrategy; }; declare const service: { BaseRemoteService: typeof BaseRemoteService; SumologicService: typeof SumologicService; LogglyService: typeof LogglyService; ConsoleService: typeof ConsoleService; ElasticsearchService: typeof ElasticsearchService; }; export { AdvancedLogger, TransformationEnum, service, strategy };