First commit on the local Gitea server, made after moving the tree off the Windows machine. Build outputs, node_modules and the AI models stay out (see .gitignore); everything the installer build needs is tracked. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
419 lines
14 KiB
HTML
419 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Server Log Viewer - Bible App</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
body {
|
|
background: #1a1a1a;
|
|
color: #e0e0e0;
|
|
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
|
|
font-size: 13px;
|
|
line-height: 1.5;
|
|
padding: 20px;
|
|
overflow-x: hidden;
|
|
}
|
|
.header {
|
|
background: #2a2a2a;
|
|
padding: 15px 20px;
|
|
border-bottom: 2px solid #4a9eff;
|
|
margin-bottom: 20px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
gap: 15px;
|
|
}
|
|
h1 {
|
|
color: #4a9eff;
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
}
|
|
.controls {
|
|
display: flex;
|
|
gap: 10px;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
}
|
|
button {
|
|
background: #4a9eff;
|
|
color: white;
|
|
border: none;
|
|
padding: 8px 16px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
transition: background 0.2s;
|
|
}
|
|
button:hover {
|
|
background: #5ab0ff;
|
|
}
|
|
button:active {
|
|
background: #3a8eef;
|
|
}
|
|
button.secondary {
|
|
background: #555;
|
|
}
|
|
button.secondary:hover {
|
|
background: #666;
|
|
}
|
|
button.danger {
|
|
background: #ff6b6b;
|
|
}
|
|
button.danger:hover {
|
|
background: #ff7b7b;
|
|
}
|
|
.filter-controls {
|
|
display: flex;
|
|
gap: 10px;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
}
|
|
.filter-input {
|
|
background: #2a2a2a;
|
|
border: 1px solid #444;
|
|
color: #e0e0e0;
|
|
padding: 6px 12px;
|
|
border-radius: 4px;
|
|
font-size: 13px;
|
|
font-family: inherit;
|
|
min-width: 200px;
|
|
}
|
|
.filter-input:focus {
|
|
outline: none;
|
|
border-color: #4a9eff;
|
|
}
|
|
.stats {
|
|
display: flex;
|
|
gap: 20px;
|
|
font-size: 12px;
|
|
color: #999;
|
|
}
|
|
.log-container {
|
|
background: #1a1a1a;
|
|
border: 1px solid #333;
|
|
border-radius: 4px;
|
|
max-height: calc(100vh - 200px);
|
|
overflow-y: auto;
|
|
overflow-x: auto;
|
|
padding: 10px;
|
|
}
|
|
.log-entry {
|
|
padding: 4px 8px;
|
|
margin: 2px 0;
|
|
border-left: 3px solid transparent;
|
|
white-space: pre-wrap;
|
|
word-wrap: break-word;
|
|
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
|
|
font-size: 12px;
|
|
}
|
|
.log-entry:hover {
|
|
background: #2a2a2a;
|
|
}
|
|
.log-entry.osc {
|
|
border-left-color: #4a9eff;
|
|
}
|
|
.log-entry.osc-feedback {
|
|
border-left-color: #51cf66;
|
|
}
|
|
.log-entry.error {
|
|
border-left-color: #ff6b6b;
|
|
color: #ff9999;
|
|
}
|
|
.log-entry.warn {
|
|
border-left-color: #ffd43b;
|
|
color: #ffe066;
|
|
}
|
|
.log-entry.info {
|
|
border-left-color: #74c0fc;
|
|
color: #a5d8ff;
|
|
}
|
|
.timestamp {
|
|
color: #666;
|
|
margin-right: 8px;
|
|
font-size: 11px;
|
|
}
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 60px 20px;
|
|
color: #666;
|
|
}
|
|
.empty-state h2 {
|
|
color: #999;
|
|
margin-bottom: 10px;
|
|
}
|
|
.auto-scroll-indicator {
|
|
position: fixed;
|
|
bottom: 20px;
|
|
right: 20px;
|
|
background: #4a9eff;
|
|
color: white;
|
|
padding: 8px 16px;
|
|
border-radius: 4px;
|
|
font-size: 12px;
|
|
opacity: 0;
|
|
transition: opacity 0.3s;
|
|
pointer-events: none;
|
|
}
|
|
.auto-scroll-indicator.visible {
|
|
opacity: 1;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<h1>📋 Server Log Viewer</h1>
|
|
<div class="controls">
|
|
<div class="filter-controls">
|
|
<input type="text" id="filterInput" class="filter-input" placeholder="Filter logs (e.g., OSC, error, feedback)">
|
|
<button onclick="clearFilter()" class="secondary">Clear Filter</button>
|
|
</div>
|
|
<button onclick="clearLogs()" class="danger">Clear Logs</button>
|
|
<button onclick="toggleAutoScroll()" id="autoScrollBtn">Auto-scroll: ON</button>
|
|
<button onclick="exportLogs()" class="secondary">Export Logs</button>
|
|
<button onclick="goBack()" class="secondary" style="background: #666;">← Back to App</button>
|
|
</div>
|
|
</div>
|
|
<div class="stats">
|
|
<span>Total Logs: <strong id="totalCount">0</strong></span>
|
|
<span>Filtered: <strong id="filteredCount">0</strong></span>
|
|
<span>Errors: <strong id="errorCount">0</strong></span>
|
|
<span>OSC Messages: <strong id="oscCount">0</strong></span>
|
|
</div>
|
|
<div class="log-container" id="logContainer">
|
|
<div class="empty-state">
|
|
<h2>Waiting for logs...</h2>
|
|
<p>Server logs will appear here when the app is running.</p>
|
|
<p style="margin-top: 10px; font-size: 11px; color: #555;">Send an OSC command from Companion to see OSC feedback logs.</p>
|
|
</div>
|
|
</div>
|
|
<div class="auto-scroll-indicator" id="autoScrollIndicator">Auto-scrolling...</div>
|
|
|
|
<script>
|
|
let logs = [];
|
|
let filteredLogs = [];
|
|
let autoScroll = true;
|
|
let filterText = '';
|
|
|
|
// Load initial logs from API
|
|
async function loadInitialLogs() {
|
|
try {
|
|
const response = await fetch('/api/logs?limit=500');
|
|
if (response.ok) {
|
|
const data = await response.json();
|
|
if (data.ok && data.logs) {
|
|
// Real-time logs may have arrived via IPC while we were awaiting the fetch.
|
|
// Replacing the array outright would drop them, so re-append any not in the snapshot.
|
|
const realtimeDuringFetch = logs.slice();
|
|
logs = data.logs.slice();
|
|
const seen = new Set(logs.map(l => JSON.stringify(l)));
|
|
realtimeDuringFetch.forEach(l => {
|
|
const k = JSON.stringify(l);
|
|
if (!seen.has(k)) { logs.push(l); seen.add(k); }
|
|
});
|
|
applyFilter();
|
|
updateStats();
|
|
}
|
|
}
|
|
} catch (e) {
|
|
console.error('Failed to load initial logs:', e);
|
|
}
|
|
}
|
|
|
|
// Listen for logs from main process (real-time updates)
|
|
if (window.electron && window.electron.ipcRenderer) {
|
|
window.electron.ipcRenderer.on('server-log', (event, logData) => {
|
|
addLog(logData);
|
|
});
|
|
}
|
|
|
|
// Load initial logs when page loads
|
|
loadInitialLogs();
|
|
|
|
// Refresh logs every 5 seconds to catch any missed ones
|
|
setInterval(() => {
|
|
if (logs.length === 0) {
|
|
loadInitialLogs();
|
|
}
|
|
}, 5000);
|
|
|
|
function addLog(logData) {
|
|
const entry = {
|
|
timestamp: new Date().toISOString(),
|
|
level: logData.level || 'log',
|
|
message: logData.message || '',
|
|
category: logData.category || '',
|
|
...logData
|
|
};
|
|
|
|
logs.push(entry);
|
|
|
|
// Keep only last 1000 logs to prevent memory issues
|
|
if (logs.length > 1000) {
|
|
logs.shift();
|
|
}
|
|
|
|
applyFilter();
|
|
updateStats();
|
|
}
|
|
|
|
function applyFilter() {
|
|
if (!filterText) {
|
|
filteredLogs = logs;
|
|
} else {
|
|
const filterLower = filterText.toLowerCase();
|
|
filteredLogs = logs.filter(log => {
|
|
const message = (log.message || '').toLowerCase();
|
|
const category = (log.category || '').toLowerCase();
|
|
const level = (log.level || '').toLowerCase();
|
|
return message.includes(filterLower) ||
|
|
category.includes(filterLower) ||
|
|
level.includes(filterLower);
|
|
});
|
|
}
|
|
|
|
renderLogs();
|
|
}
|
|
|
|
function renderLogs() {
|
|
const container = document.getElementById('logContainer');
|
|
|
|
if (filteredLogs.length === 0) {
|
|
container.innerHTML = `
|
|
<div class="empty-state">
|
|
<h2>No logs found</h2>
|
|
<p>${filterText ? 'Try adjusting your filter.' : 'Logs will appear here when available.'}</p>
|
|
</div>
|
|
`;
|
|
return;
|
|
}
|
|
|
|
container.innerHTML = filteredLogs.map(log => {
|
|
const time = new Date(log.timestamp).toLocaleTimeString();
|
|
const level = log.level || 'log';
|
|
const category = log.category || '';
|
|
|
|
// Determine CSS class based on log content
|
|
let logClass = level;
|
|
if (category.includes('OSC Feedback') || log.message.includes('[OSC Feedback]')) {
|
|
logClass += ' osc-feedback';
|
|
} else if (category.includes('OSC') || log.message.includes('[OSC]')) {
|
|
logClass += ' osc';
|
|
}
|
|
|
|
return `
|
|
<div class="log-entry ${logClass}">
|
|
<span class="timestamp">${time}</span>
|
|
<span class="message">${escapeHtml(log.message)}</span>
|
|
</div>
|
|
`;
|
|
}).join('');
|
|
|
|
if (autoScroll) {
|
|
container.scrollTop = container.scrollHeight;
|
|
}
|
|
}
|
|
|
|
function escapeHtml(text) {
|
|
const div = document.createElement('div');
|
|
div.textContent = text;
|
|
return div.innerHTML;
|
|
}
|
|
|
|
function updateStats() {
|
|
document.getElementById('totalCount').textContent = logs.length;
|
|
document.getElementById('filteredCount').textContent = filteredLogs.length;
|
|
document.getElementById('errorCount').textContent = logs.filter(l => l.level === 'error').length;
|
|
document.getElementById('oscCount').textContent = logs.filter(l =>
|
|
l.category.includes('OSC') || (l.message && l.message.includes('[OSC]'))
|
|
).length;
|
|
}
|
|
|
|
function clearLogs() {
|
|
if (confirm('Clear all logs? This cannot be undone.')) {
|
|
logs = [];
|
|
filteredLogs = [];
|
|
renderLogs();
|
|
updateStats();
|
|
}
|
|
}
|
|
|
|
function clearFilter() {
|
|
document.getElementById('filterInput').value = '';
|
|
filterText = '';
|
|
applyFilter();
|
|
}
|
|
|
|
function toggleAutoScroll() {
|
|
autoScroll = !autoScroll;
|
|
const btn = document.getElementById('autoScrollBtn');
|
|
btn.textContent = `Auto-scroll: ${autoScroll ? 'ON' : 'OFF'}`;
|
|
btn.style.background = autoScroll ? '#4a9eff' : '#555';
|
|
|
|
if (autoScroll) {
|
|
const container = document.getElementById('logContainer');
|
|
container.scrollTop = container.scrollHeight;
|
|
}
|
|
}
|
|
|
|
function exportLogs() {
|
|
const logText = filteredLogs.map(log => {
|
|
const time = new Date(log.timestamp).toISOString();
|
|
return `[${time}] [${log.level.toUpperCase()}] ${log.message}`;
|
|
}).join('\n');
|
|
|
|
const blob = new Blob([logText], { type: 'text/plain' });
|
|
const url = URL.createObjectURL(blob);
|
|
const a = document.createElement('a');
|
|
a.href = url;
|
|
a.download = `bible-app-logs-${new Date().toISOString().split('T')[0]}.txt`;
|
|
document.body.appendChild(a);
|
|
a.click();
|
|
document.body.removeChild(a);
|
|
URL.revokeObjectURL(url);
|
|
}
|
|
|
|
function goBack() {
|
|
// Try to go back to the main app
|
|
if (window.history.length > 1) {
|
|
window.history.back();
|
|
} else {
|
|
// Fallback: navigate to root
|
|
window.location.href = '/';
|
|
}
|
|
}
|
|
|
|
// Filter input handler
|
|
document.getElementById('filterInput').addEventListener('input', (e) => {
|
|
filterText = e.target.value;
|
|
applyFilter();
|
|
});
|
|
|
|
// Show auto-scroll indicator when user scrolls manually
|
|
const container = document.getElementById('logContainer');
|
|
const indicator = document.getElementById('autoScrollIndicator');
|
|
|
|
container.addEventListener('scroll', () => {
|
|
const isAtBottom = container.scrollHeight - container.scrollTop <= container.clientHeight + 10;
|
|
if (autoScroll && !isAtBottom) {
|
|
indicator.classList.add('visible');
|
|
setTimeout(() => {
|
|
indicator.classList.remove('visible');
|
|
}, 2000);
|
|
}
|
|
});
|
|
|
|
// Initial render
|
|
renderLogs();
|
|
updateStats();
|
|
</script>
|
|
</body>
|
|
</html>
|