MCPcopy Create free account
hub / github.com/Roy3838/Observer / initTauriLogForwarding

Function initTauriLogForwarding

app/src/utils/platform.ts:169–193  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

167 * Call this once at app startup.
168 */
169export const initTauriLogForwarding = async (): Promise<(() => void) | null> => {
170 if (!isTauri()) {
171 return null;
172 }
173
174 try {
175 const { attachLogger } = await import('@tauri-apps/plugin-log');
176
177 const detach = await attachLogger(({ level, message }) => {
178 // Map Tauri log levels to our LogLevel enum
179 const logLevel = level <= 1 ? LogLevel.ERROR
180 : level === 2 ? LogLevel.WARNING
181 : level === 3 ? LogLevel.INFO
182 : LogLevel.DEBUG;
183
184 Logger.log(logLevel, 'rust', message);
185 });
186
187 Logger.info('platform', 'Tauri log forwarding initialized');
188 return detach;
189 } catch (err) {
190 console.warn('[Platform] Failed to initialize Tauri log forwarding:', err);
191 return null;
192 }
193};
194
195// Cached Tauri fetch function (loaded lazily on first use)
196let tauriFetchFn: typeof fetch | null = null;

Callers 1

main.tsxFile · 0.90

Calls 4

isTauriFunction · 0.85
infoMethod · 0.80
warnMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected