mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-11-09 05:24:49 +09:00
Drop unused useLogs and logsSourceLabel
Nothing imports either; useServiceLogStream replaced the hook, which also left loading stuck on a read error.
This commit is contained in:
1 parent
411ce694da
commit
0704c42daa
2 files changed
-47
No files matched your search
@@ -58,44 +58,4 @@ export function useMetrics(useWebSocket = true, pollInterval = DEFAULT_POLL_INTE
|
||||
return { metrics, loading, error, connected, refresh: fetchMetrics };
|
||||
}
|
||||
|
||||
export function useLogs(filepath) {
|
||||
const [logs, setLogs] = useState([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (!filepath) return;
|
||||
|
||||
// Fetch initial logs
|
||||
api.readLog(filepath, 100).then(result => {
|
||||
if (result.success) {
|
||||
setLogs(result.lines);
|
||||
}
|
||||
setLoading(false);
|
||||
});
|
||||
|
||||
// Connect WebSocket for real-time updates
|
||||
socketService.connect();
|
||||
|
||||
const unsubLine = socketService.on('log_line', (data) => {
|
||||
if (data.filepath === filepath) {
|
||||
setLogs(prev => [...prev.slice(-499), data.line]);
|
||||
}
|
||||
});
|
||||
|
||||
// Subscribe to log stream
|
||||
socketService.subscribeLogs(filepath);
|
||||
|
||||
return () => {
|
||||
unsubLine();
|
||||
socketService.unsubscribeLogs();
|
||||
};
|
||||
}, [filepath]);
|
||||
|
||||
const clearLogs = useCallback(() => {
|
||||
setLogs([]);
|
||||
}, []);
|
||||
|
||||
return { logs, loading, clearLogs };
|
||||
}
|
||||
|
||||
export default useMetrics;
|
||||
@@ -22,10 +22,3 @@ export function logsToText(data) {
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
// Which backend the output came from ('Docker Compose', 'Docker Compose
|
||||
// (legacy)', ...), when the response says. Worth showing: it explains an empty
|
||||
// log more often than the log itself does.
|
||||
export function logsSourceLabel(data) {
|
||||
return (data && typeof data === 'object' && data.source_label) || '';
|
||||
}
|
||||
Reference in new issue
Block a user