react-native-xlog-jsi
Version:
It allows you to easily use https://github.com/Tencent/mars#mars-xlog inside your React Native applications.
42 lines (32 loc) • 1.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
const LINKING_ERROR = `The package 'react-native-xlog-jsi' doesn't seem to be linked. Make sure: \n\n` + _reactNative.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 = _reactNative.NativeModules.XlogJsi ? _reactNative.NativeModules.XlogJsi : new Proxy({}, {
get() {
throw new Error(LINKING_ERROR);
}
});
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);
}
}
exports.default = Xlog;
//# sourceMappingURL=index.js.map