Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Release mode diagnostics in React Native

Tags:

Is there any way to get React Native to output all console.log calls to same place NSLog goes?

Is there a way I can see the outputs from console.log in Release mode?

If not is there an NSLog helper for react native I can use?

(note I know that in Debug mode I have a multitude of ways of getting this info, but I am having specific issue with Release mode that I need to diagnose.)

like image 967
Sam Saffron Avatar asked Aug 22 '16 22:08

Sam Saffron


People also ask

How do you debug react native in release mode?

Connecting a React Native app to React Native Debugger To connect your app with React Native Debugger, you need to run your app and start debug mode. To start debug mode, shake your mobile device or press Command + Shift + Z or Ctrl + M and choose the debug option. We're all set to begin using React Native Debugger.

How do I debug react native app in Xcode?

You can access the developer menu by shaking your device or by selecting "Shake Gesture" inside the Hardware menu in the iOS Simulator. You can also use the ⌘D keyboard shortcut when your app is running in the iOS Simulator, or ⌘M when running in an Android emulator on macOS and Ctrl+M on Windows and Linux.

What does react native bundle do?

Bundling. Most React apps will have their files “bundled” using tools like Webpack, Rollup or Browserify. Bundling is the process of following imported files and merging them into a single file: a “bundle”. This bundle can then be included on a webpage to load an entire app at once.


1 Answers

In AppDelegate.m

#import <React/RCTLog.h> 

Then in didFinishLaunchingWithOptions

RCTSetLogThreshold(RCTLogLevelInfo - 1); 

This sets the react logger to log all levels to NSLog as opposed to the release default which is: RCTLogLevelError which is console.error I guess :)

This allows you to have a totally honest "release" mode build with all the verbose logging you want.

like image 118
Sam Saffron Avatar answered Sep 28 '22 05:09

Sam Saffron