feat: comprehensive debug logging across all controller modules

Add detailed [DEBUG] logging to every controller module when
logging.level is set to "debug". Each module with stateful debug
uses SetDebug(bool) wired from main.go. Covers stacks, backup,
cloudflare, integrations, system, monitor, settings, scheduler,
web handlers, storage, metrics, API, selfupdate, and assets.

Also includes the app export/import (.fab bundles) feature from
v0.32.0 and its debug page integration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-26 18:14:43 +01:00
parent f6caea8067
commit 95c821deb2
54 changed files with 5015 additions and 82 deletions
@@ -184,6 +184,27 @@
</div>
</div>
<!-- Section 9: App Export/Import -->
<div class="card debug-section" id="section-appexport">
<div class="card-header debug-section-header" onclick="toggleSection('appexport')">
<h3>Alkalmazás Export/Import</h3>
<span class="section-toggle"></span>
</div>
<div class="card-body debug-section-body" style="display:none">
<div id="appexport-status"><span class="text-muted">Betöltés...</span></div>
<div class="debug-actions" style="margin-top:.75rem">
<button class="btn btn-secondary btn-sm" id="btn-appexport-scan" data-label="Csomagok keresése" onclick="scanAppBundles()">Csomagok keresése</button>
<span class="debug-result" id="btn-appexport-scan-result"></span>
<button class="btn btn-secondary btn-sm" id="btn-appexport-cleanup" data-label="Temp fájlok törlése" onclick="triggerAction('btn-appexport-cleanup','/api/debug/appexport/cleanup','POST')">Temp fájlok törlése</button>
<span class="debug-result" id="btn-appexport-cleanup-result"></span>
<button class="btn btn-secondary btn-sm" id="btn-appexport-refresh" data-label="Frissítés" onclick="loadSectionData('appexport')">Frissítés</button>
</div>
<div id="appexport-bundles" style="display:none;margin-top:1rem"></div>
</div>
</div>
<!-- Section 8: Log Viewer -->
<div class="card debug-section" id="section-logs">
<div class="card-header debug-section-header" onclick="toggleSection('logs')">
@@ -285,6 +306,7 @@ function loadSectionData(id) {
case 'telemetry': break; // no auto-load, user triggers manually
case 'selfupdate': loadSelfUpdateStatus(); break;
case 'dr': loadDRStatus(); break;
case 'appexport': loadAppExportStatus(); break;
case 'logs': initLogViewer(); break;
}
}
@@ -693,6 +715,137 @@ function renderTelemetryDetail(data) {
detail.style.display = 'block';
}
// ── Section 9: App Export/Import ──
function loadAppExportStatus() {
document.getElementById('appexport-status').innerHTML = '<span class="text-muted">Betöltés...</span>';
fetch('/api/debug/appexport/status', {headers: csrfHeaders()}).then(function(r){return r.json()}).then(function(data) {
if (!data.ok) { document.getElementById('appexport-status').innerHTML = '<span class="text-muted">Nem elérhető</span>'; return; }
renderAppExportStatus(data.data);
}).catch(function(e) {
document.getElementById('appexport-status').innerHTML = '<span class="debug-result-error">Hiba: ' + e.message + '</span>';
});
}
function renderAppExportStatus(d) {
if (!d.available) {
document.getElementById('appexport-status').innerHTML = '<span class="text-muted">App export modul nem elérhető</span>';
return;
}
var html = '<div class="debug-kv-grid">';
html += '<dt>Debug mód</dt><dd>' + (d.debug_enabled ? '<span class="state-text-green">Aktív</span>' : 'Inaktív') + '</dd>';
html += '<dt>Verzió</dt><dd class="mono">' + (d.version||'-') + '</dd>';
html += '<dt>Csomagok</dt><dd>' + (d.bundle_count||0) + ' db</dd>';
html += '<dt>Temp fájlok</dt><dd>' + (d.stale_temp_count||0) + ' db';
if (d.stale_temp_count > 0) html += ' <span style="color:var(--warning)">⚠</span>';
html += '</dd>';
html += '</div>';
// Active job
if (d.has_active_job && d.active_job) {
var j = d.active_job;
html += '<h4 style="margin-top:.75rem">Aktív feladat</h4>';
html += '<div class="debug-kv-grid">';
html += '<dt>Típus</dt><dd>' + (j.job_type||'-') + '</dd>';
html += '<dt>Stack</dt><dd>' + (j.display_name || j.stack_name || '-') + '</dd>';
html += '<dt>Állapot</dt><dd>' + (j.running ? '🔄 Fut' : j.done ? '✅ Kész' : '⏸ Várakozik') + '</dd>';
if (j.error) html += '<dt>Hiba</dt><dd class="debug-result-error">' + escapeHtml(j.error) + '</dd>';
if (j.output_path) html += '<dt>Kimenet</dt><dd class="mono" style="font-size:.75rem">' + escapeHtml(j.output_path) + '</dd>';
if (j.output_size) html += '<dt>Méret</dt><dd>' + j.output_size + '</dd>';
html += '</div>';
if (j.steps && j.steps.length > 0) {
html += '<div style="margin-top:.5rem">';
j.steps.forEach(function(s) {
var icon = s.status === 'done' ? '✓' : s.status === 'running' ? '⟳' : s.status === 'failed' ? '✗' : '○';
var cls = s.status === 'failed' ? 'color:var(--danger)' : s.status === 'done' ? 'color:var(--success)' : s.status === 'running' ? 'color:var(--primary)' : 'color:var(--text-muted)';
html += '<div style="font-size:.85rem;padding:.1rem 0;' + cls + '">' + icon + ' ' + escapeHtml(s.label);
if (s.error) html += ' <span style="font-size:.8rem">(' + escapeHtml(s.error) + ')</span>';
html += '</div>';
});
html += '</div>';
}
}
// Export dirs
if (d.export_dirs && d.export_dirs.length > 0) {
html += '<h4 style="margin-top:.75rem">Export könyvtárak</h4>';
html += '<table class="info-table debug-table"><tr><th>Útvonal</th><th>Cimke</th><th>Létezik</th></tr>';
d.export_dirs.forEach(function(dir) {
html += '<tr><td class="mono" style="font-size:.75rem">' + escapeHtml(dir.path) + '</td><td>' + (dir.label||'-') + '</td><td>' + (dir.exists ? '✅' : '❌') + '</td></tr>';
});
html += '</table>';
}
// Stale temp files
if (d.stale_temp_files && d.stale_temp_files.length > 0) {
html += '<h4 style="margin-top:.75rem;color:var(--warning)">Elavult temp fájlok</h4>';
html += '<ul style="font-size:.85rem;margin:0;padding-left:1.5rem">';
d.stale_temp_files.forEach(function(f) {
html += '<li class="mono" style="font-size:.75rem">' + escapeHtml(f) + '</li>';
});
html += '</ul>';
}
document.getElementById('appexport-status').innerHTML = html;
// Auto-refresh if a job is running
if (d.has_active_job && d.active_job && d.active_job.running) {
startPolling('appexport', 2000, function() {
fetch('/api/debug/appexport/status', {headers: csrfHeaders()}).then(function(r){return r.json()}).then(function(data) {
if (data.ok) renderAppExportStatus(data.data);
}).catch(function(){});
});
}
}
function scanAppBundles() {
var btn = document.getElementById('btn-appexport-scan');
var result = document.getElementById('btn-appexport-scan-result');
btn.disabled = true;
btn.textContent = 'Keresés...';
result.className = 'debug-result';
result.textContent = '';
fetch('/api/debug/appexport/bundles', {headers: csrfHeaders()}).then(function(r){return r.json()}).then(function(data) {
if (data.ok) {
result.className = 'debug-result debug-result-ok';
result.textContent = data.message;
if (data.data && data.data.bundles) {
renderAppBundles(data.data.bundles);
}
} else {
result.className = 'debug-result debug-result-error';
result.textContent = data.error || 'Hiba';
}
}).catch(function(e) {
result.className = 'debug-result debug-result-error';
result.textContent = 'Hálózati hiba: ' + e.message;
}).finally(function() {
btn.disabled = false;
btn.textContent = btn.dataset.label;
});
}
function renderAppBundles(bundles) {
var container = document.getElementById('appexport-bundles');
if (!bundles || bundles.length === 0) {
container.innerHTML = '<span class="text-muted">Nem található .fab csomag.</span>';
container.style.display = 'block';
return;
}
var html = '<table class="info-table debug-table"><tr><th>Alkalmazás</th><th>Dátum</th><th>Méret</th><th>Tároló</th><th>Titkos</th><th>DB</th><th>HDD</th><th>Elérés</th></tr>';
bundles.forEach(function(b) {
html += '<tr>';
html += '<td><strong>' + escapeHtml(b.display_name || b.app_name) + '</strong></td>';
html += '<td>' + (b.exported_at || '-') + '</td>';
html += '<td>' + (b.size_human || '-') + '</td>';
html += '<td>' + escapeHtml(b.drive_label || b.drive_path) + '</td>';
html += '<td>' + (b.encrypted ? '🔒' : '-') + '</td>';
html += '<td>' + (b.has_db ? '✅' : '-') + '</td>';
html += '<td>' + (b.needs_hdd ? '✅' : '-') + '</td>';
html += '<td class="mono" style="font-size:.7rem;max-width:200px;overflow:hidden;text-overflow:ellipsis">' + escapeHtml(b.path) + '</td>';
html += '</tr>';
});
html += '</table>';
container.innerHTML = html;
container.style.display = 'block';
}
// ── Helpers ──
function fmtTime(ts) {
if (!ts) return '-';