From 40b03bc59567527a291fff938a99e69500c9ffb2 Mon Sep 17 00:00:00 2001 From: Alexey Prokhorov Date: Sat, 6 Apr 2024 09:09:45 +0800 Subject: [PATCH] fix: Error when calling readAllLogs, fixes #414 --- src/node/transports/file/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/node/transports/file/index.js b/src/node/transports/file/index.js index 9ba0a72..0df6639 100644 --- a/src/node/transports/file/index.js +++ b/src/node/transports/file/index.js @@ -125,8 +125,13 @@ function fileTransportFactory( } function readAllLogs({ fileFilter = (f) => f.endsWith('.log') } = {}) { + initializeOnFirstAccess(); const logsPath = path.dirname(transport.resolvePathFn(pathVariables)); + if (!fs.existsSync(logsPath)) { + return []; + } + return fs.readdirSync(logsPath) .map((fileName) => path.join(logsPath, fileName)) .filter(fileFilter)