feat: per-session log files

New "Neues Log pro Session" checkbox in settings. When enabled,
each app session creates a separate log file with timestamp
(e.g. fileuploader-2026-03-11_20-30-15.log). File is only created
when an upload actually completes. When disabled, behaves as before
(single appending log file).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Administrator 2026-03-11 21:45:08 +01:00
parent ff2991cabd
commit 35334e365f
3 changed files with 29 additions and 1 deletions

View File

@ -27,6 +27,7 @@ const DEFAULTS = {
alwaysOnTop: false, alwaysOnTop: false,
shutdownAfterFinish: 'nothing', // nothing | sleep | shutdown | restart shutdownAfterFinish: 'nothing', // nothing | sleep | shutdown | restart
logFilePath: '', logFilePath: '',
sessionLog: false,
resumeQueueOnLaunch: true, resumeQueueOnLaunch: true,
parallelUploadCount: 0, // 0 = use per-hoster limits only parallelUploadCount: 0, // 0 = use per-hoster limits only
scaleParallelUploads: false, scaleParallelUploads: false,

24
main.js
View File

@ -68,7 +68,7 @@ function getDefaultLogFilePath() {
return path.join(baseDir, 'fileuploader.log'); return path.join(baseDir, 'fileuploader.log');
} }
function getLogFilePath() { function getBaseLogFilePath() {
const config = configStore.load(); const config = configStore.load();
const customPath = config && config.globalSettings const customPath = config && config.globalSettings
? String(config.globalSettings.logFilePath || '').trim() ? String(config.globalSettings.logFilePath || '').trim()
@ -76,6 +76,28 @@ function getLogFilePath() {
return customPath || getDefaultLogFilePath(); return customPath || getDefaultLogFilePath();
} }
// Session log: one file per app session, created lazily on first upload
let sessionLogPath = null;
function getLogFilePath() {
const config = configStore.load();
const useSessionLog = config && config.globalSettings && config.globalSettings.sessionLog;
if (!useSessionLog) return getBaseLogFilePath();
// Lazy: generate session log path on first call
if (!sessionLogPath) {
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}`);
}
return sessionLogPath;
}
function appendUploadLog(hoster, link, fileName) { function appendUploadLog(hoster, link, fileName) {
try { try {
const logPath = getLogFilePath(); const logPath = getLogFilePath();

View File

@ -1591,6 +1591,10 @@ function renderSettings() {
<input type="text" class="key-input settings-autosave" id="logFilePathInput" value="${escapeAttr(globalSettings.logFilePath || '')}" placeholder="Standardpfad verwenden"> <input type="text" class="key-input settings-autosave" id="logFilePathInput" value="${escapeAttr(globalSettings.logFilePath || '')}" placeholder="Standardpfad verwenden">
<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">
<label>Neues Log pro Session</label>
<input type="checkbox" class="settings-autosave" id="sessionLogInput" ${globalSettings.sessionLog ? 'checked' : ''}>
</div>
</div> </div>
`; `;
container.appendChild(generalPanel); container.appendChild(generalPanel);
@ -1693,6 +1697,7 @@ async function saveSettings(options = {}) {
const globalSettings = { const globalSettings = {
...(config.globalSettings || {}), ...(config.globalSettings || {}),
logFilePath: (document.getElementById('logFilePathInput')?.value || '').trim(), logFilePath: (document.getElementById('logFilePathInput')?.value || '').trim(),
sessionLog: !!document.getElementById('sessionLogInput')?.checked,
resumeQueueOnLaunch: !!document.getElementById('resumeQueueOnLaunchInput')?.checked, resumeQueueOnLaunch: !!document.getElementById('resumeQueueOnLaunchInput')?.checked,
parallelUploadCount: Math.max(0, Math.min(100, parseInt(document.getElementById('parallelUploadCountInput')?.value || '0', 10) || 0)), parallelUploadCount: Math.max(0, Math.min(100, parseInt(document.getElementById('parallelUploadCountInput')?.value || '0', 10) || 0)),
scaleParallelUploads: !!document.getElementById('scaleParallelUploadsInput')?.checked, scaleParallelUploads: !!document.getElementById('scaleParallelUploadsInput')?.checked,