import { get } from './apiClient';
import type { RequestLog, PageResponse } from '../types/monitoring';

export const searchLogs = (params: Record<string, string | number | undefined>) => {
  const query = Object.entries(params)
    .filter(([, v]) => v !== undefined && v !== '')
    .map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
    .join('&');
  return get<PageResponse<RequestLog>>(`/monitoring/logs${query ? '?' + query : ''}`);
};

export const getLogDetail = (id: number) => get<RequestLog>(`/monitoring/logs/${id}`);
