UNPKG

react-native-xlog-jsi

Version:

It allows you to easily use https://github.com/Tencent/mars#mars-xlog inside your React Native applications.

31 lines (26 loc) 1.34 kB
import { NativeModules, Platform } from 'react-native'; const LINKING_ERROR = `The package 'react-native-xlog-jsi' doesn't seem to be linked. Make sure: \n\n` + Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n'; // global func declaration for JSI functions const XlogJsi = NativeModules.XlogJsi ? NativeModules.XlogJsi : new Proxy({}, { get() { throw new Error(LINKING_ERROR); } }); export default class Xlog { constructor() { let rootDirectory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'xlogs'; let namePrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'XLog'; let cacheDays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3; let isConsoleLogOpen = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !!__DEV__; if (!global.xlogAppenderFlush) { XlogJsi.install(rootDirectory, namePrefix, cacheDays, isConsoleLogOpen); } } static async appenderFlush() { let isSync = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; return global.xlogAppenderFlush(isSync); // return XlogJsi.appenderFlush(isSync); } } //# sourceMappingURL=index.js.map