mirror of
https://github.com/neosubhamoy/neodlp.git
synced 2025-12-20 00:49:33 +05:30
feat: added neodlp logger and log viewer
This commit is contained in:
26
src/helpers/use-logger.ts
Normal file
26
src/helpers/use-logger.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { useLogsStore } from "@/services/store";
|
||||
|
||||
export function useLogger() {
|
||||
const logs = useLogsStore((state) => state.logs);
|
||||
const addLog = useLogsStore((state) => state.addLog);
|
||||
const clearLogs = useLogsStore((state) => state.clearLogs);
|
||||
|
||||
const logger = {
|
||||
info: (context: string, message: string) => {
|
||||
addLog({ timestamp: Date.now(), level: 'info', context, message });
|
||||
},
|
||||
warning: (context: string, message: string) => {
|
||||
addLog({ timestamp: Date.now(), level: 'warning', context, message });
|
||||
},
|
||||
error: (context: string, message: string) => {
|
||||
addLog({ timestamp: Date.now(), level: 'error', context, message });
|
||||
},
|
||||
debug: (context: string, message: string) => {
|
||||
addLog({ timestamp: Date.now(), level: 'debug', context, message });
|
||||
},
|
||||
getLogs: () => logs,
|
||||
clearLogs,
|
||||
};
|
||||
|
||||
return logger;
|
||||
}
|
||||
Reference in New Issue
Block a user