rn-device-logger
v1.0.11
Published
React Native logger for real devices without the needs to enable Debug JS Remotely & JS Dev Mode to maximize app performance.
Downloads
35
Maintainers
Readme
rn-device-logger
Description
React Native logger for real devices without the needs to enable 'Debug JS Remotely' & 'JS Dev Mode' to maximize app performance.
Getting started
$ npm install rn-device-logger --save
$ npm install -g npm-run
Usage
Start logger server:
$ cd [YOUR_PROJECT]
(Ex: $ cd /User/ducth/mighty-rn)
$ npm-run logger
// index.js or app.js or wherever you want
import RNDeviceLogger from "rn-device-logger";
/**
* Host address or IP address of dev machine that project is running on.
* Usually same address of your debug host server that you config on real device
*/
const DEBUG_URL = "http://192.168.2.69";
RNDeviceLogger.logDebug(DEBUG_URL, obj); // Log debug (blue color tag)
RNDeviceLogger.logError(DEBUG_URL, obj); // Log error (red color tag)
// Example usage: define function in window to use anywhere in project without import. I'm lazy at writing import statement everytime :))
window.log = obj => {
console.log(obj);
RNDeviceLogger.logDebug(DEBUG_URL, obj);
};
Open web browser and type: [HOST_ADDRESS]:8181 (React Native run on port 8081 so I pick 8181 ).
Ex: http://192.168.2.69:8181 (or localhost:8181 if you open browser in same machine)
Your logs will be there, JSON will be pretty formatted.