import { appendFile, mkdir } from 'fs/promises';
import { join } from 'path';
export class RuntimeDiagnosticsLogger {
    enabled;
    logDir;
    constructor(enabled, logDir) {
        this.enabled = enabled;
        this.logDir = logDir;
    }
    async writeSample(sample) {
        if (!this.enabled) {
            return;
        }
        await this.appendJsonl('app-runtime.jsonl', sample);
    }
    async writeEvent(event) {
        if (!this.enabled) {
            return;
        }
        await this.appendJsonl('app-events.jsonl', event);
    }
    async appendJsonl(fileName, record) {
        try {
            await mkdir(this.logDir, { recursive: true });
            await appendFile(join(this.logDir, fileName), `${JSON.stringify(record)}\n`, 'utf8');
        }
        catch {
            return;
        }
    }
}
//# sourceMappingURL=runtime-diagnostics-logger.js.map