@plust/datasleuth
Version:
Build LLM-powered research pipelines and output structured data.
87 lines (86 loc) • 2.37 kB
TypeScript
/**
* Logging utility for the @plust/datasleuth package
*/
/**
* Available log levels in order of increasing severity
*/
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
/**
* Configuration options for the logger
*/
export interface LoggerOptions {
/** Minimum level to log (defaults to 'info') */
level?: LogLevel;
/** Include timestamp in log messages */
includeTimestamp?: boolean;
/** Include current step name in log messages */
includeStepName?: boolean;
/** Whether to log to the console */
logToConsole?: boolean;
/** Additional custom loggers to send log messages to */
customLoggers?: Array<(level: LogLevel, message: string, ...args: unknown[]) => void>;
}
/**
* Logger class that handles log message formatting and output
*/
export declare class Logger {
private level;
private options;
private currentStep?;
/**
* Creates a new logger instance
*/
constructor(options?: LoggerOptions);
/**
* Set the current step name for step-specific logging
*/
setCurrentStep(stepName?: string): void;
/**
* Get the current step name
*/
getCurrentStep(): string | undefined;
/**
* Set the minimum log level
*/
setLogLevel(level: LogLevel): void;
/**
* Log a debug message
*/
debug(message: string, ...args: unknown[]): void;
/**
* Log an info message
*/
info(message: string, ...args: unknown[]): void;
/**
* Log a warning message
*/
warn(message: string, ...args: unknown[]): void;
/**
* Log an error message
*/
error(message: string, ...args: unknown[]): void;
/**
* Log a message with the specified level
*/
private log;
/**
* Check if the given log level should be logged based on the current minimum level
*/
private shouldLog;
/**
* Format the log message with optional timestamp and step name
*/
private formatMessage;
/**
* Get the appropriate console method for the log level
*/
private getConsoleMethod;
}
/**
* Global logger instance
*/
export declare const logger: Logger;
/**
* Creates a step-specific logger that automatically includes the step name
*/
export declare function createStepLogger(stepName: string): Pick<Logger, 'debug' | 'info' | 'warn' | 'error'>;