npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

antu-rn-xlog

v0.5.3

Published

Wecha's Xlog framework for react-native

Downloads

2

Readme

react-native-xlog

此包克隆至react-native-xlog

修复 XlogPackage.java 文件报错问题

RN0.47.0版本删除了这个继承关系,去除 @override 注释

Wechat's Xlog framework for RN.

You can send log to Xlog, and manager Xlog lifecycle. Handle js/native crash log in production builds.

attention: you will see the crash log only when you restart your app

Feature

  • [x] iOS: send log to xlog for js function
  • [x] iOS: RCTLog output to xlog
  • [x] iOS: crash message output to xlog
  • [x] android: send log to xlog for js function
  • [x] android: RCTLog output to xlog
  • [x] android: crash message output in the xlog

Get Start

Add it to your project

  1. Run npm i -S react-native-xlog
  2. Add Xlog to you project.

Linking iOS

run react-native link react-native-xlog to link the library.

if Header Search Paths does not have the $(SRCROOT)/../node_modules/react-native/React + recursive, linking may fail.

Android

  1. config gradle script
  • add dependency in android/app/build.gradle
dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile "com.tencent.mars:mars-xlog:1.0.4" //<--add here
    compile project(":react-native-xlog") //<--add here
}
  • add react-native-xlog project in root project's settings.gradle
include ':react-native-xlog'
project(':react-native-xlog').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-xlog/android')
  • add variables in root project's build.gradle
ext {
    MARS_XLOG_VERSION_NAME='1.0.4'
    MARS_XLOG_VERSION_NAME_SUFFIX = ''
}
  1. add XLogPackage
...
import com.engsshi.xlog.XLogPackage;
...

public class MainApplication extends Application implements ReactApplication {
    ...
    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        @Override
        protected boolean getUseDeveloperSupport() {
            return BuildConfig.DEBUG;
        }

        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.asList(
                    new MainReactPackage(),
                    new XLogPackage()  // <--add here
            );
        }
    };
   ...
}   
  1. init xlog settings.
    JS has to exception type: fatal exception(just throw JavascriptException in native) and soft exception(use FLog.e in native). you can find this from RN source file: ExceptionsManagerModule.java and support you two init way:
  • XLogModule.init(xLogSetting): normal log, include FLog
  • XLogModule.initWithNativeCrashInclude(xLogSetting, this): normal log and crash log (JS fatal exception and native uncaught exception)
...
import android.os.Environment;
import com.engsshi.xlog.XLogModule;
import com.engsshi.xlog.XLogSetting;
...

public class MainApplication extends Application implements ReactApplication {
  ...
   @Override
    public void onCreate() {
        super.onCreate();
        ...
        final String appName = this.getString(R.string.app_name);
        final String logPath = Environment.getExternalStorageDirectory().getAbsolutePath() + '/' + appName + "/log";

        XLogSetting xLogSetting = XLogSetting.builder()
                .setLevel(XLogSetting.LEVEL_DEBUG)
                .setPath(logPath)
                .setCacheDir("")
                .setAppenderMode(XLogSetting.APPENDER_MODE_ASYNC)
                .setNamePrefix(appName)
                .setOpenConsoleLog(true)
                .build();
        XLogModule.init(xLogSetting)
        //XLogModule.initWithNativeCrashInclude(xLogSetting, this);
        ...
  }
  ...
}
  1. if your want to log early, rather than delay to RNView render done, your can turn on xlog early, just add in Application's onCreate() after XLogModule init done.
public class MainApplication extends Application implements ReactApplication {
  ...
   @Override
    public void onCreate() {
       // xlog init here ....
        ...
        XLogModule.open(); //optional, for this, you can log before into RNView 
        ...
  }
  ...
}

Usage

import Xlog from 'react-native-xlog';

Xlog.verbose('tag', 'log');
Xlog.debug('tag', 'log');
Xlog.info('tag', 'log');
Xlog.warn('tag', 'log');
Xlog.error('tag', 'log');
Xlog.fatal('tag', 'log');

Decode log file

Use this script to decode log file:

  • myapp.mmap2
  • myapp_20170723.xlog
python decode_mars_log_file.py ~/Downloads/log/myapp_20170723.xlog