feat: better logs

- added ability to write debug logs for development builds
- added filtering to log page
- modified filter button to allow for multiple selection if required
This commit is contained in:
herrrta
2025-03-28 19:03:36 -04:00
parent 587d419502
commit 1394eae01e
27 changed files with 204 additions and 133 deletions

View File

@@ -265,7 +265,7 @@ export const useSettings = () => {
if (!api) return;
const settings = await api.getStreamyfinPluginConfig().then(
({ data }) => {
writeInfoLog(`Got remote settings: ${data?.settings}`);
writeInfoLog("Got plugin settings", data?.settings);
return data?.settings;
},
(err) => undefined,

View File

@@ -4,7 +4,7 @@ import type React from "react";
import { createContext, useContext } from "react";
import { storage } from "./mmkv";
type LogLevel = "INFO" | "WARN" | "ERROR";
export type LogLevel = "INFO" | "WARN" | "ERROR" | "DEBUG";
interface LogEntry {
timestamp: string;
@@ -62,6 +62,11 @@ export const writeInfoLog = (message: string, data?: any) =>
writeToLog("INFO", message, data);
export const writeErrorLog = (message: string, data?: any) =>
writeToLog("ERROR", message, data);
export const writeDebugLog = (message: string, data?: any) => {
if (process.env.DEBUG === "1") {
writeToLog("DEBUG", message, data);
}
}
export const readFromLog = (): LogEntry[] => {
const logs = storage.getString("logs");