UNPKG

cross-log

Version:

A universal logging package that works in both browser and Node.js environments with environment variable configuration

160 lines 5.13 kB
/** * Module augmentation for cross-log plugin system * This file provides comprehensive TypeScript module augmentation to add plugin methods to the ILogger interface */ import { ApiPlugin, DatabasePlugin, AnalyticsPlugin, PerformancePlugin, SecurityPlugin, ApiPluginConfig, DatabasePluginConfig, AnalyticsPluginConfig, PerformancePluginConfig, SecurityPluginConfig, Plugin } from './types'; /** * Augment the core ILogger interface to include plugin methods */ declare module '../core/types' { /** * Enhanced ILogger interface with full plugin support and type safety */ interface ILogger { /** * API logging methods - available when api plugin is loaded */ api?: ApiPlugin; /** * Database logging methods - available when database plugin is loaded */ database?: DatabasePlugin; /** * Analytics logging methods - available when analytics plugin is loaded */ analytics?: AnalyticsPlugin; /** * Performance logging methods - available when performance plugin is loaded */ performance?: PerformancePlugin; /** * Security logging methods - available when security plugin is loaded */ security?: SecurityPlugin; /** * Type-safe plugin management with proper return types */ use(plugin: Plugin): ILogger; /** * Get a specific plugin by name */ getPlugin(name: string): Plugin | undefined; /** * Check if a plugin is loaded */ hasPlugin(name: string): boolean; /** * Remove a plugin */ removePlugin(name: string): void; /** * Access to all loaded plugins */ plugins?: Record<string, Plugin>; } } /** * Global module augmentation for cross-log package */ declare module '../index' { /** * Re-export the enhanced ILogger interface with all plugin methods */ interface ILogger { api?: ApiPlugin; database?: DatabasePlugin; analytics?: AnalyticsPlugin; performance?: PerformancePlugin; security?: SecurityPlugin; use(plugin: Plugin): ILogger; getPlugin(name: string): Plugin | undefined; hasPlugin(name: string): boolean; removePlugin(name: string): void; plugins?: Record<string, Plugin>; } /** * Export plugin method interfaces for direct use */ interface ApiPluginMethods extends ApiPlugin { } interface DatabasePluginMethods extends DatabasePlugin { } interface AnalyticsPluginMethods extends AnalyticsPlugin { } interface PerformancePluginMethods extends PerformancePlugin { } interface SecurityPluginMethods extends SecurityPlugin { } /** * Export plugin configuration interfaces */ interface ApiPluginConfiguration extends ApiPluginConfig { } interface DatabasePluginConfiguration extends DatabasePluginConfig { } interface AnalyticsPluginConfiguration extends AnalyticsPluginConfig { } interface PerformancePluginConfiguration extends PerformancePluginConfig { } interface SecurityPluginConfiguration extends SecurityPluginConfig { } /** * Plugin registry for type-safe plugin access */ interface PluginRegistry { api: { config: ApiPluginConfig; methods: ApiPlugin; }; database: { config: DatabasePluginConfig; methods: DatabasePlugin; }; analytics: { config: AnalyticsPluginConfig; methods: AnalyticsPlugin; }; performance: { config: PerformancePluginConfig; methods: PerformancePlugin; }; security: { config: SecurityPluginConfig; methods: SecurityPlugin; }; } /** * Interface for extending the plugin registry with custom plugins * Users can augment this interface to add their own plugin types * * @example * declare module 'cross-log' { * interface CustomPluginRegistry { * myPlugin: { * config: MyPluginConfig; * methods: MyPluginMethods; * }; * } * } */ interface CustomPluginRegistry { } } /** * Export type aliases for easier access */ export type ApiPluginMethods = ApiPlugin; export type DatabasePluginMethods = DatabasePlugin; export type AnalyticsPluginMethods = AnalyticsPlugin; export type PerformancePluginMethods = PerformancePlugin; export type SecurityPluginMethods = SecurityPlugin; export type ApiPluginConfiguration = ApiPluginConfig; export type DatabasePluginConfiguration = DatabasePluginConfig; export type AnalyticsPluginConfiguration = AnalyticsPluginConfig; export type PerformancePluginConfiguration = PerformancePluginConfig; export type SecurityPluginConfiguration = SecurityPluginConfig; /** * Export empty object to make this a module */ export {}; //# sourceMappingURL=augmentation.d.ts.map