30 lines
636 B
TypeScript
30 lines
636 B
TypeScript
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;
|
|
}
|
|
}
|