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

react-native-android-log

v1.1.0

Published

Easy and useful log methods for Android apps in debug or release mode, with minimal impact

Downloads

71

Readme

react-native-android-log

npm License

Easy and useful log methods for Android apps in debug or release mode, with minimal impact.

Works with RN 0.50+, Gradle plugin 3.1.x and Gradle 4.4 or later.

Default build is for minSdkVersion 21 and targetSdkVersion 27, but you can configure this.

NOTE:

In iOS, the default level is SUPPRESS, which disables the output. If you change it, console.log will be used.

Install

  1. Install the module from npm and link it:

    $ yarn add react-native-android-log
    $ react-native link react-native-android-log
  2. Replace 'compile' with 'implementation' in your android/app/build.gradle. It must looks like:

    implementation project(':react-native-android-log')

For VS Code users

Optional: You can add the tag used by Log to the logCatArguments properties in .vscode/launch.json

This example will include React Native warnings and errors, and all the messages from App in the "OUTPUT" panel:

    ...
    {
      "name": "Debug Android",
      "program": "${workspaceRoot}/.vscode/launchReactNative.js",
      "type": "reactnative",
      "request": "launch",
      "platform": "android",
      "sourceMaps": true,
      "outDir": "${workspaceRoot}/.vscode/.react",
      "logCatArguments": [
        "*:S",
        "ReactNative:W",
        "ReactNativeJS:W",
        "App:V"
      ]
    },

SDK version Settings

Optional: In your android/build.gradle file, set the SDK versions that your app is using.

Example with the predefined values:

ext {
    def buildToolsVersion  = '27.0.3'
    def minSdkVersion      = 16
    def compileSdkVersion  = 27
    def targetSdkVersion   = 27
}

Usage

Log messages in your JavaScript files:

import Log from 'react-native-android-log'

// Set the default priority level (optional)
Log.setLevel(__DEV__ ? Log.VERBOSE : Log.WARN)

...
Log.v('Verbose message')    // no output in release builds
Log.w('Debugging')

// debugging message with amother tag:
Log.d('Proc2', 'warning')

...and see the output in the console through adb:

$ adb logcat -s App:V Proc2:V

or in the OUPUT panel of VS Code, if you are using the React Native Tools extension.

API

Contstants

Numeric levels, from most to least verbosity:

Constant | Description ---------|------------ VERBOSE | Used by Log.v, outputs nothing unless you use Log.setLevel(Log.VERBOSE) DEBUG | Priority constant for Log.d INFO | Priority constant for Log.i WARN | Priority constant for Log.w ERROR | Priority constant for Log.e SUPPRESS | This is a special constant used to disable logging

Methods

  • setTag(tag: string)

    Sets the tag to use by the logging methods without a tag parameter.

    The predefined tag is "App".

  • setLevel(tag: string | null, level: number)

    Allows you to change the logging level for a specific tag or, if you pass a null tag, the default level for all the tags.

    The predefined level is DEBUG for debug builds and ERROR for release builds.

  • getLevel(tag?: string | null)

    Return the level for a specific tag.

    If tag is null, not specified, or does not have a specific level, this method return the default level for all the tags.

  • print(level: string, tag: string, msg: string)

  • print(level: string, msg: string)

    Base method for all the one-letter logging methods.

  • v (VERBOSE)

  • d (DEBUG)

  • i (INFO)

  • w (WARN)

  • e (ERROR)

    The above methods are one-letter shortcuts to the print method with the corresponding priority level and can be invoked with or without the tag parameter:

    method(tag: string, msg: string)

    method(msg: string)

    If you omit the tag, the one specified with setTag will be used, or the predefined tag "App".

License

MIT © 2018 Alberto Martínez