import 'reflect-metadata'; import { ChildProcess } from 'child_process'; /** * Utils for logging ChildProcess output to files. * - logging stdout and stderr to files * - real-time monitoring of output * - special event callbacks on specific output strings * - caching last N lines of output for quick access */ export declare namespace UtilsProcessLogger { interface ProcessFileLoggerOptions extends Record { name: string; id?: string | number; pid?: number; ppid?: number; hash?: string; utime?: string; } interface SpecialEventInProcessLogger { stdout?: { stringInStream: string; callback: (data: string) => void; }[]; stderr?: { stringInStream: string; callback: (data: string) => void; }[]; } const baseDirTaonProcessLogs: () => string; const getLogsFiles: (options: T, baseDir: string) => string[]; /** * Logs the stdout and stderr of a ChildProcess to a file. */ class ProcessFileLogger { /** * Options used to generate the log file name. */ private dataForFilename; private options?; private _logFilePath; private writeStream; private _processLogFilename; private lastNLinesFromStderr; private lastNLinesFromStdout; private lastNLinesFromOfOutput; get processLogFilename(): string | null; get processLogAbsFilePath(): string | null; constructor( /** * Options used to generate the log file name. */ dataForFilename: T, options?: { baseDir?: string; specialEvent?: SpecialEventInProcessLogger; }); startLogging(proc: ChildProcess, cacheCallback?: { /** * @default 40 */ cacheLinesMax?: number; /** * Throttle in ms for callback update() */ throttleMs?: number; /** * Special callback function for saving stuff in db/memory or elsewhere */ update: (opt: { outputLines: string; stderrLines: string; stdoutLines: string; }) => void; }): void; stopLogging(): void; /** * Externally update the log file with additional stdout/stderr data. */ update(stdout: string, stderr?: string): void; } /** * Perfect for real-time logs with a sticky top box message. * * Example: * const stickyBox = UtilsProcessLogger.createStickyTopBox('My Sticky Message'); * stickyBox.update('Initial log content...'); * * // Later updates * stickyBox.update('More log content...'); * * // To clear the sticky box and logs * stickyBox.clear(); */ const createStickyTopBox: (message: string) => { update: (content: string) => void; clear: () => void; }; }