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 <noreply@anthropic.com>
This commit is contained in:
parent
127d3fd830
commit
5aaa1ef578
25
main.js
25
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) {
|
||||
|
||||
@ -1890,7 +1890,7 @@ function renderSettings() {
|
||||
<button class="btn btn-xs btn-secondary" id="chooseLogFilePathBtn">Ordner wählen</button>
|
||||
</div>
|
||||
<div class="settings-row">
|
||||
<label>Neues Log pro Session</label>
|
||||
<label>Neues Log pro Tag</label>
|
||||
<input type="checkbox" class="settings-autosave" id="sessionLogInput" ${globalSettings.sessionLog ? 'checked' : ''}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user