From c4ad84ab061d4277528e2b00244f4f619f4a7a09 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sat, 11 Jan 2025 01:14:16 +0100 Subject: [PATCH] refactor(backend_log): print error to the log --- src/routes/api/backend_log.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/routes/api/backend_log.ts b/src/routes/api/backend_log.ts index a3ad441b4..318f894c6 100644 --- a/src/routes/api/backend_log.ts +++ b/src/routes/api/backend_log.ts @@ -4,6 +4,8 @@ import { readFile } from "fs/promises"; import { join } from "path"; import dateUtils from "../../services/date_utils.js"; import dataDir from "../../services/data_dir.js"; +import log from "../../services/log.js"; + const { LOG_DIR } = dataDir; async function getBackendLog() { @@ -11,6 +13,8 @@ async function getBackendLog() { const file = join(LOG_DIR, `trilium-${dateUtils.localNowDate()}.log`); return await readFile(file, "utf8"); } catch (e) { + log.error((e instanceof Error) ? e : "Reading the Backend Log failed with an unknown error."); + // most probably the log file does not exist yet - https://github.com/zadam/trilium/issues/1977 return ""; }