Frontend requests log on backend

This commit is contained in:
2024-10-02 21:54:54 +02:00
parent 75753051f9
commit 7dfb172aeb
4 changed files with 118 additions and 1 deletions

View File

@ -0,0 +1,29 @@
import { Dayjs } from "dayjs";
import { APIClient } from "./ApiClient";
export type LogSeverity = "Debug" | "Info" | "Warn" | "Error";
export interface LogEntry {
device_id: string;
time: number;
severity: LogSeverity;
message: string;
}
export class LogsAPI {
/**
* Request the logs from the server
*
* @param date The date that contains the requested date
*/
static async GetLogs(date: Dayjs): Promise<LogEntry[]> {
const day = Math.floor(date.unix() / (3600 * 24));
const res = await APIClient.exec({
uri: `/logging/logs?day=${day}`,
method: "GET",
});
return res.data;
}
}