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();
|
return customPath || getDefaultLogFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Session log: one file per app session, created lazily on first upload
|
// Daily log: one file per day, reused across sessions on the same day
|
||||||
let sessionLogPath = null;
|
let _dailyLogPath = null;
|
||||||
|
let _dailyLogDate = null;
|
||||||
|
|
||||||
function getLogFilePath() {
|
function getLogFilePath() {
|
||||||
const config = configStore.load();
|
const config = configStore.load();
|
||||||
const useSessionLog = config && config.globalSettings && config.globalSettings.sessionLog;
|
const useDailyLog = config && config.globalSettings && config.globalSettings.sessionLog;
|
||||||
if (!useSessionLog) return getBaseLogFilePath();
|
if (!useDailyLog) return getBaseLogFilePath();
|
||||||
|
|
||||||
// Lazy: generate session log path on first call
|
const now = new Date();
|
||||||
if (!sessionLogPath) {
|
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 base = getBaseLogFilePath();
|
||||||
const dir = path.dirname(base);
|
const dir = path.dirname(base);
|
||||||
const ext = path.extname(base);
|
const ext = path.extname(base);
|
||||||
const name = path.basename(base, ext);
|
const name = path.basename(base, ext);
|
||||||
const now = new Date();
|
_dailyLogPath = path.join(dir, `${name}-${today}${ext}`);
|
||||||
const pad = (n) => String(n).padStart(2, '0');
|
_dailyLogDate = today;
|
||||||
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}`);
|
|
||||||
}
|
}
|
||||||
return sessionLogPath;
|
return _dailyLogPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendUploadLog(hoster, link, fileName) {
|
function appendUploadLog(hoster, link, fileName) {
|
||||||
|
|||||||
@ -1890,7 +1890,7 @@ function renderSettings() {
|
|||||||
<button class="btn btn-xs btn-secondary" id="chooseLogFilePathBtn">Ordner wählen</button>
|
<button class="btn btn-xs btn-secondary" id="chooseLogFilePathBtn">Ordner wählen</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="settings-row">
|
<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' : ''}>
|
<input type="checkbox" class="settings-autosave" id="sessionLogInput" ${globalSettings.sessionLog ? 'checked' : ''}>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user