1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/apps/dashboard/features/logs/api/useLogEntries.ts

26 lines
650 B
TypeScript
Raw Normal View History

2024-12-17 21:35:45 +03:00
import { Api } from '@jellyfin/sdk';
import { getSystemApi } from '@jellyfin/sdk/lib/utils/api/system-api';
import { useQuery } from '@tanstack/react-query';
import { useApi } from 'hooks/useApi';
const fetchLogEntries = async (api?: Api) => {
if (!api) {
console.error('[useLogEntries] No API instance available');
return;
}
const response = await getSystemApi(api).getServerLogs();
return response.data;
};
export const useLogEntries = () => {
const { api } = useApi();
return useQuery({
queryKey: [ 'LogEntries' ],
queryFn: () => fetchLogEntries(api),
enabled: !!api
});
};