react-native-device-log
Description
A debug-view that prints your debug-messages in a neat listview.
Supports different levels of log-messages, complex data (With pretty printing), timers for measuring perf and much more.
Adheres to a simple, async, protocol for saving messages where you can plug in your own adapter, or
use AsyncStorage from React Native to persist log-messages between session. (Or just use simple session in-memory storage).
Also tracks Connectivity of Device and App-State-changes (Background, Idle, Active).
Will also, if you choose to (flag), track exceptions in your app and in React Native and log linenumbers and methods
so you can track crashes in production.
Configure how many messages that should be rendered in the ListView and how many messages should be persisted.
All built to be efficent and fast.
Install:
npm install react-native-device-log --save
Example:
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
AsyncStorage
} from 'react-native';
import deviceLog, {LogView, InMemoryAdapter} from 'react-native-device-log';
deviceLog.init(AsyncStorage
,{
logToConsole : false,
logRNErrors : true,
maxNumberToRender : 2000,
maxNumberToPersist : 2000
}).then(() => {
});
deviceLog.startTimer('start-up');
class AwesomeProject extends Component {
componentDidMount() {
deviceLog.logTime('start-up');
deviceLog.log("Hello", "world!");
deviceLog.info("A info message");
deviceLog.debug("A debug message", {test: "test"});
deviceLog.success("A success message");
deviceLog.logTime('start-up');
deviceLog.stopTimer('start-up');
setTimeout(() => {
deviceLog.error("I'm late!!");
}, 3000);
}
render() {
return (
<LogView inverted={false} multiExpanded={true} timeStampFormat='HH:mm:ss'></LogView>
);
}
}
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);