@incubrain/helpers
Version:
41 lines (40 loc) • 1.35 kB
TypeScript
interface LogOptions {
maxFileSize?: number;
maxFiles?: number;
pretty?: boolean;
rotateOnLimit?: boolean;
timestamp?: boolean;
format?: "json" | "jsonsl";
}
export declare class FileLogger {
private readonly baseFilePath;
private readonly options;
private currentFile;
private writeStream;
private currentSize;
private isRotating;
private readonly logName;
constructor(baseFilePath: string, options?: LogOptions, logName?: string);
private getCurrentFilePath;
private initStream;
private rotateFiles;
private formatLogEntry;
write(entries: any, level?: "info" | "warn" | "error" | "debug"): Promise<void>;
info(entries: any): Promise<void>;
warn(entries: any): Promise<void>;
error(entries: any): Promise<void>;
debug(entries: any): Promise<void>;
}
/**
* Creates or retrieves a logger instance
* @param fileName Base file name for the logs
* @param options Logger options
* @param loggerName Unique name for this logger instance
* @returns FileLogger instance
*/
export declare function createFileLogger(fileName: string, options?: LogOptions, loggerName?: string): FileLogger;
/**
* Legacy function to maintain backward compatibility
*/
export declare function logFile(fileName: string, newValues: any, options?: LogOptions): Promise<void>;
export {};