Files
streamyfin/utils/log.ts
Fredrik Burmester ca7fd382f2 wip
2024-08-18 13:30:12 +02:00

40 lines
720 B
TypeScript

import { atom } from "jotai";
import { atomWithStorage, createJSONStorage } from "jotai/utils";
type LogLevel = "INFO" | "WARN" | "ERROR";
interface LogEntry {
timestamp: string;
level: LogLevel;
message: string;
data?: any;
}
const logsAtom = atom([]);
export const writeToLog = async (
level: LogLevel,
message: string,
data?: any
) => {
const newEntry: LogEntry = {
timestamp: new Date().toISOString(),
level: level,
message: message,
data: data,
};
const logs: LogEntry[] = [];
logs.push(newEntry);
const maxLogs = 100;
};
export const readFromLog = async (): Promise<LogEntry[]> => {
return [];
};
export const clearLogs = async () => {};
export default logsAtom;