UNPKG

@appzung/react-native-code-push

Version:

React Native plugin for the CodePush service

44 lines (40 loc) 1.1 kB
"use strict"; const defaultLogger = (_level, message) => { console.log(`[CodePush] ${message}`); }; let currentLogger = defaultLogger; /** * Set a custom logger function to handle all CodePush logs * * @param logger A function that takes a log level and message and handles the logging * @example * ``` * import { setLogger, LogLevel } from '@appzung/react-native-code-push'; * * // Custom logger that sends critical logs to a crash reporting service * setLogger((level, message) => { * // Always log to console * console.log(`[CodePush] ${message}`); * * // Send error logs to crash reporting * if (level === LogLevel.ERROR) { * MyCrashReportingService.log(`CodePush error: ${message}`); * } * }); * ``` */ export const setLogger = logger => { currentLogger = logger; }; /** * Get the current logger function * @returns The current logger function */ export const getLogger = () => currentLogger; /** * Reset the logger to the default implementation */ export const resetLogger = () => { currentLogger = defaultLogger; }; //# sourceMappingURL=logger.js.map