logs-interceptor
Version:
High-performance, production-ready log interceptor for Node.js applications with Loki integration
108 lines • 3.17 kB
TypeScript
import { LogsInterceptor } from './logger';
import { LogsInterceptorConfig } from './types';
export { LogsInterceptor } from './logger';
export * from './types';
export * from './utils';
/**
* Initialize the logs interceptor with configuration
* Can be called multiple times - subsequent calls will update the configuration
*/
export declare function init(userConfig?: Partial<LogsInterceptorConfig>): LogsInterceptor;
/**
* Get the global logger instance
* Throws an error if not initialized
*/
export declare function getLogger(): LogsInterceptor;
/**
* Check if the logger is initialized
*/
export declare function isInitialized(): boolean;
/**
* Destroy the global logger instance
*/
export declare function destroy(): Promise<void>;
export declare const logger: {
/**
* Log a debug message
*/
debug: (message: string, context?: Record<string, unknown>) => void;
/**
* Log an info message
*/
info: (message: string, context?: Record<string, unknown>) => void;
/**
* Log a warning message
*/
warn: (message: string, context?: Record<string, unknown>) => void;
/**
* Log an error message
*/
error: (message: string, context?: Record<string, unknown>) => void;
/**
* Log a fatal message
*/
fatal: (message: string, context?: Record<string, unknown>) => void;
/**
* Track an event
*/
trackEvent: (eventName: string, properties?: Record<string, unknown>) => void;
/**
* Force flush logs
*/
flush: () => Promise<void>;
/**
* Get metrics
*/
getMetrics: () => import("./types").LoggerMetrics | undefined;
/**
* Get health status
*/
getHealth: () => import("./types").HealthStatus | undefined;
};
declare const _default: {
init: typeof init;
getLogger: typeof getLogger;
isInitialized: typeof isInitialized;
destroy: typeof destroy;
logger: {
/**
* Log a debug message
*/
debug: (message: string, context?: Record<string, unknown>) => void;
/**
* Log an info message
*/
info: (message: string, context?: Record<string, unknown>) => void;
/**
* Log a warning message
*/
warn: (message: string, context?: Record<string, unknown>) => void;
/**
* Log an error message
*/
error: (message: string, context?: Record<string, unknown>) => void;
/**
* Log a fatal message
*/
fatal: (message: string, context?: Record<string, unknown>) => void;
/**
* Track an event
*/
trackEvent: (eventName: string, properties?: Record<string, unknown>) => void;
/**
* Force flush logs
*/
flush: () => Promise<void>;
/**
* Get metrics
*/
getMetrics: () => import("./types").LoggerMetrics | undefined;
/**
* Get health status
*/
getHealth: () => import("./types").HealthStatus | undefined;
};
LogsInterceptor: typeof LogsInterceptor;
};
export default _default;
//# sourceMappingURL=index.d.ts.map