From 5aaa1ef578f277482c4e646e9fe223c3cfc021e6 Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 12 Mar 2026 05:23:05 +0100 Subject: [PATCH] feat: daily log files instead of per-session Log files are now created per day (e.g. fileuploader-2026-03-12.log) instead of per app session. Multiple sessions on the same day append to the same file. Rolls over automatically at midnight. Co-Authored-By: Claude Opus 4.6 --- main.js | 25 ++++++++++++++----------- renderer/app.js | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/main.js b/main.js index d996d29..64d9d0b 100644 --- a/main.js +++ b/main.js @@ -81,26 +81,29 @@ function getBaseLogFilePath() { return customPath || getDefaultLogFilePath(); } -// Session log: one file per app session, created lazily on first upload -let sessionLogPath = null; +// Daily log: one file per day, reused across sessions on the same day +let _dailyLogPath = null; +let _dailyLogDate = null; function getLogFilePath() { const config = configStore.load(); - const useSessionLog = config && config.globalSettings && config.globalSettings.sessionLog; - if (!useSessionLog) return getBaseLogFilePath(); + const useDailyLog = config && config.globalSettings && config.globalSettings.sessionLog; + if (!useDailyLog) return getBaseLogFilePath(); - // Lazy: generate session log path on first call - if (!sessionLogPath) { + const now = new Date(); + const pad = (n) => String(n).padStart(2, '0'); + const today = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`; + + // Reuse path if same day, otherwise generate new + if (_dailyLogDate !== today) { const base = getBaseLogFilePath(); const dir = path.dirname(base); const ext = path.extname(base); const name = path.basename(base, ext); - const now = new Date(); - const pad = (n) => String(n).padStart(2, '0'); - const ts = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}_${pad(now.getHours())}-${pad(now.getMinutes())}-${pad(now.getSeconds())}`; - sessionLogPath = path.join(dir, `${name}-${ts}${ext}`); + _dailyLogPath = path.join(dir, `${name}-${today}${ext}`); + _dailyLogDate = today; } - return sessionLogPath; + return _dailyLogPath; } function appendUploadLog(hoster, link, fileName) { diff --git a/renderer/app.js b/renderer/app.js index f5d0d56..c6c9983 100644 --- a/renderer/app.js +++ b/renderer/app.js @@ -1890,7 +1890,7 @@ function renderSettings() {
- +