Files
paseo/packages/desktop/src/diagnostics/tail-file.ts
T
Mohamed BoudraandGitHub f21c997b17 Include desktop app logs in diagnostics (#1914)
* fix(diagnostics): include desktop app logs

Settings diagnostics now collect the Electron main-process log separately from daemon.log so desktop startup and environment-probe failures are included in app reports.

* refactor(desktop): share log tail reader

* fix(diagnostics): surface desktop app log read errors

* refactor(diagnostics): tighten desktop report API
2026-07-06 17:50:45 +02:00

22 lines
622 B
TypeScript

import { readFileSync } from "node:fs";
interface TailFileOptions {
throwOnReadError?: boolean;
}
export function tailFile(filePath: string, lines = 50, options: TailFileOptions = {}): string {
try {
const content = readFileSync(filePath, "utf-8");
return content.split("\n").filter(Boolean).slice(-lines).join("\n");
} catch (error) {
if (options.throwOnReadError && !isMissingFileError(error)) {
throw error;
}
return "";
}
}
function isMissingFileError(error: unknown): boolean {
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
}