@bernierllc/logging
Version:
A comprehensive logging package with Winston integration for audit and system logging
136 lines • 4.49 kB
TypeScript
import { Logger } from './mocks/coreLogger';
import { ConfigurationSource } from './config/loadConfiguration';
import { ServiceLoggingRuntimeConfig, ResolvedServiceLoggingConfig } from './config/types';
import { CoreLoggerBridge } from './coreLoggerBridge';
import winston from 'winston';
/**
* Service Logging Manager
*
* This class orchestrates the entire logging service, managing both:
* 1. Core @bernierllc/logger integration with runtime configuration
* 2. Service-level Winston-based system and audit logging
*
* It provides a unified interface that bridges the gap between the
* atomic core logger and the comprehensive service-level logging needs.
*/
export declare class ServiceLoggingManager {
private config;
private configSources;
private coreLogger?;
private systemLogger?;
private auditLogger?;
private coreLoggerBridge?;
private isInitialized;
constructor(runtimeConfig?: Partial<ServiceLoggingRuntimeConfig>);
/**
* Initialize configuration synchronously
*/
private initializeConfiguration;
/**
* Load and merge configuration from all sources (async version for core logger integration)
*/
private loadConfigurationWithCoreLogger;
/**
* Initialize the logging service with all configured loggers
*/
initialize(): Promise<void>;
/**
* Initialize core logger with service configuration
*/
private initializeCoreLogger;
/**
* Initialize service-level Winston loggers
*/
private initializeServiceLoggers;
/**
* Map service configuration to core logger configuration
*/
private mapServiceConfigToCoreConfig;
/**
* Create Winston system logger from service configuration
*/
private createWinstonSystemLogger;
/**
* Create Winston audit logger from service configuration
*/
private createWinstonAuditLogger;
/**
* Merge configuration objects recursively
*/
private mergeConfiguration;
/**
* Get the core logger instance (preferred for new code)
*/
getCoreLogger(): Logger | undefined;
/**
* Get the core logger bridge (Winston-compatible interface)
*/
getCoreLoggerBridge(): CoreLoggerBridge | undefined;
/**
* Get the Winston system logger (legacy compatibility)
*/
getSystemLogger(): winston.Logger | undefined;
/**
* Get the Winston audit logger
*/
getAuditLogger(): winston.Logger | undefined;
/**
* Get resolved configuration
*/
getConfiguration(): ResolvedServiceLoggingConfig;
/**
* Get configuration sources for transparency
*/
getConfigurationSources(): ConfigurationSource[];
/**
* Log using the best available logger (core logger preferred, Winston fallback)
*/
log(level: string, message: string, metadata?: Record<string, unknown>): void;
/**
* Convenience logging methods
*/
error(message: string, error?: Error, metadata?: Record<string, unknown>): void;
warn(message: string, metadata?: Record<string, unknown>): void;
info(message: string, metadata?: Record<string, unknown>): void;
debug(message: string, metadata?: Record<string, unknown>): void;
/**
* Audit logging method
*/
audit(entry: {
action: string;
userId?: string;
resource?: string;
result: 'success' | 'failure';
details?: Record<string, unknown>;
}): void;
/**
* Check if service is initialized
*/
isReady(): boolean;
/**
* Shutdown all loggers gracefully
*/
shutdown(): Promise<void>;
}
/**
* Create or get the global service logging manager
*/
export declare function createServiceLoggingManager(runtimeConfig?: Partial<ServiceLoggingRuntimeConfig>): Promise<ServiceLoggingManager>;
/**
* Get the global service logging manager (must be created first)
*/
export declare function getServiceLoggingManager(): ServiceLoggingManager | null;
/**
* Reset global service logging manager (for testing)
*/
export declare function resetServiceLoggingManager(): void;
/**
* Convenience function to create a logger with runtime configuration
*/
export declare function createConfiguredLogger(runtimeConfig?: Partial<ServiceLoggingRuntimeConfig>): Promise<{
coreLogger?: Logger;
systemLogger?: winston.Logger;
auditLogger?: winston.Logger;
manager: ServiceLoggingManager;
}>;
//# sourceMappingURL=serviceLoggingManager.d.ts.map