import { Platform, Share } from 'react-native'; import { getGeolocationProNative } from './native/getNativeModule'; const Native = getGeolocationProNative(); export interface LogQuery { start?: number; end?: number; order?: number; limit?: number; } export const Logger = { async error(message: string): Promise { await Native?.log?.('ERROR', message); }, async warn(message: string): Promise { await Native?.log?.('WARN', message); }, async info(message: string): Promise { await Native?.log?.('INFO', message); }, async debug(message: string): Promise { await Native?.log?.('DEBUG', message); }, async getLog(query: LogQuery = {}): Promise { return Native?.getLog?.(query) ?? ''; }, async destroyLog(): Promise { await Native?.destroyLog?.(); }, /** Share log via system sheet (email, AirDrop, etc.) */ async emailLog(email: string, query: LogQuery = {}): Promise { const log = await Logger.getLog(query); if (Platform.OS === 'ios' || Platform.OS === 'android') { await Share.share({ message: log, title: `GeolocationPro log → ${email}` }); } }, async uploadLog(url: string, query: LogQuery = {}): Promise { return Native?.uploadLog?.(url, query) ?? false; }, }; export default Logger;