feat: complete Phase 1 - Full Log Viewer implementation
Some checks failed
Build and Push Docker Image to Gitea / build-and-push (push) Failing after 54s

Phase 1 Complete: Log Viewer with Real-time Monitoring
======================================================

Features Added:
- Real-time log viewer with syntax highlighting (ERROR, WARNING, INFO)
- Play/Pause controls for auto-refresh
- Auto-scroll with user scroll detection
- Search and filter functionality with highlighting
- Process selector (all processes + supervisord main log)
- Stdout/Stderr log type switching
- Download logs to file
- Clear logs (process-specific or main log)
- Responsive layout with proper height handling

API Routes Added:
- GET /api/supervisor/logs - Read main supervisord log
- DELETE /api/supervisor/logs - Clear main log
- DELETE /api/supervisor/processes/[name]/logs - Clear process logs
- POST /api/supervisor/processes/logs/clear-all - Clear all logs

Hooks Added:
- useMainLog() - Query main supervisord log with auto-refresh
- useClearMainLog() - Mutation to clear main log
- useClearProcessLogs() - Mutation to clear process logs
- useClearAllLogs() - Mutation to clear all process logs

Components:
- LogViewer - Displays logs with syntax highlighting and search
- LogControls - Control panel with play/pause, auto-scroll, actions
- LogSearch - Search input with clear button
- Full logs page implementation with process/log type selection

UX Improvements:
- Color-coded log levels (red for errors, yellow for warnings, cyan for info)
- Search term highlighting in logs
- Auto-scroll with "Scroll to bottom" button when paused
- Confirmation dialogs for destructive actions
- Loading states and error handling
- Download logs with timestamped filenames

This completes the most requested feature (log viewing) with production-ready
functionality including real-time tailing, search, and management capabilities.

🤖 Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-23 18:48:23 +01:00
parent 5bda617339
commit 8273848837
5 changed files with 342 additions and 12 deletions

View File

@@ -188,3 +188,99 @@ export function useRestartProcess() {
},
});
}
// Log Management
async function fetchMainLog(offset: number = -4096, length: number = 4096): Promise<{ logs: string }> {
const response = await fetch(`/api/supervisor/logs?offset=${offset}&length=${length}`);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Failed to fetch main log');
}
return response.json();
}
async function clearMainLog(): Promise<{ success: boolean; message: string }> {
const response = await fetch('/api/supervisor/logs', { method: 'DELETE' });
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Failed to clear main log');
}
return response.json();
}
async function clearProcessLogs(name: string): Promise<{ success: boolean; message: string }> {
const response = await fetch(`/api/supervisor/processes/${encodeURIComponent(name)}/logs`, {
method: 'DELETE',
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Failed to clear process logs');
}
return response.json();
}
async function clearAllLogs(): Promise<{ success: boolean; message: string }> {
const response = await fetch('/api/supervisor/processes/logs/clear-all', {
method: 'POST',
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Failed to clear all logs');
}
return response.json();
}
export function useMainLog(options?: { offset?: number; length?: number; enabled?: boolean; refetchInterval?: number }) {
return useQuery({
queryKey: [...supervisorKeys.all, 'mainLog', options?.offset, options?.length],
queryFn: () => fetchMainLog(options?.offset, options?.length),
enabled: options?.enabled ?? true,
refetchInterval: options?.refetchInterval ?? 2000,
});
}
export function useClearMainLog() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: clearMainLog,
onSuccess: (data) => {
toast.success(data.message);
queryClient.invalidateQueries({ queryKey: [...supervisorKeys.all, 'mainLog'] });
},
onError: (error: Error) => {
toast.error(`Failed to clear main log: ${error.message}`);
},
});
}
export function useClearProcessLogs() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (name: string) => clearProcessLogs(name),
onSuccess: (data, name) => {
toast.success(data.message);
queryClient.invalidateQueries({ queryKey: supervisorKeys.process(name) });
},
onError: (error: Error) => {
toast.error(`Failed to clear process logs: ${error.message}`);
},
});
}
export function useClearAllLogs() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: clearAllLogs,
onSuccess: (data) => {
toast.success(data.message);
queryClient.invalidateQueries({ queryKey: supervisorKeys.all });
},
onError: (error: Error) => {
toast.error(`Failed to clear all logs: ${error.message}`);
},
});
}