@rollercoaster-dev/rd-logger
Version:
A neurodivergent-friendly logger for Rollercoaster.dev projects
91 lines (90 loc) • 3.4 kB
TypeScript
import { LogLevel, LoggerConfig } from './logger.config';
import { Transport } from './transports';
import { Formatter } from './formatters';
import { SensitiveLoggingApproval } from './sensitive';
/**
* Enhanced neuro-friendly logger class
*/
export declare class Logger {
private config;
private transports;
private formatter;
constructor(options?: Partial<LoggerConfig>);
/**
* Initialize transports based on configuration
*/
private initializeTransports;
/**
* Main logging function
* @param level Log level
* @param message Log message
* @param context Additional context (optional)
*/
log(level: LogLevel, message: string, context?: Record<string, any>): void;
debug(msg: string, ctx?: Record<string, any>): void;
info(msg: string, ctx?: Record<string, any>): void;
warn(msg: string, ctx?: Record<string, any>): void;
error(msg: string, ctx?: Record<string, any>): void;
fatal(msg: string, ctx?: Record<string, any>): void;
/**
* Logs an error object directly
* @param msg Prefix message
* @param error Error object
* @param additionalContext Additional context (optional)
*/
logError(msg: string, error: Error, additionalContext?: Record<string, any>): void;
/**
* Explicitly log sensitive data with approval information
* This method should only be used in exceptional circumstances where logging sensitive data is necessary
* @param level Log level
* @param message Log message
* @param data Data containing sensitive information
* @param approval Approval information for logging sensitive data
*/
logWithSensitiveData(level: LogLevel, message: string, data: Record<string, any>, approval: SensitiveLoggingApproval): void;
/**
* Convenience method for logging sensitive data with info level
*/
infoWithSensitiveData(message: string, data: Record<string, any>, approval: SensitiveLoggingApproval): void;
/**
* Convenience method for logging sensitive data with error level
*/
errorWithSensitiveData(message: string, data: Record<string, any>, approval: SensitiveLoggingApproval): void;
/**
* Update the logger's configuration dynamically
* @param options Partial configuration options to update
*/
configure(options: Partial<LoggerConfig>): void;
/**
* Set the log level dynamically
* @param level New log level to set
*/
setLevel(level: LogLevel): void;
/**
* Update configuration options dynamically
* @param options Partial configuration options to update
* @alias configure - Provided for API consistency
*/
updateConfig(options: Partial<LoggerConfig>): void;
/**
* Add a transport to the logger
* @param transport Transport to add
*/
addTransport(transport: Transport): void;
/**
* Remove a transport from the logger by name
* @param name Name of the transport to remove
* @returns Whether the transport was found and removed
*/
removeTransport(name: string): boolean;
/**
* Set the formatter for the logger
* @param formatter Formatter to use
*/
setFormatter(formatter: Formatter): void;
/**
* Clean up resources used by the logger
* Should be called when the logger is no longer needed
*/
cleanup(): void;
}