15 lines
702 B
TypeScript
15 lines
702 B
TypeScript
import { usePublicKey } from "../providers/AccountProvider/usePublicKey";
|
|
import { useUserCache } from "../providers/InformationProvider/useUserCache";
|
|
|
|
export function useLogger(view : string = 'general') {
|
|
const publicKey = usePublicKey();
|
|
const userInfo = useUserCache(publicKey);
|
|
|
|
const logFunction = (message : string) => {
|
|
const publicTrimmed = publicKey.substring(0, 10) + '...' + publicKey.substring(publicKey.length - 10);
|
|
const logString = `${userInfo ? `[${userInfo.title}]` : `[unknown]`} [${publicTrimmed}] [${view}] [${new Date().toISOString()}] ${message}`;
|
|
window.electron.ipcRenderer.invoke('logger:log', logString);
|
|
}
|
|
|
|
return logFunction;
|
|
} |