I was going through react native code and found the following code in one of the files:
#define RCTLog(...) _RCTLog(RCTLogLevelInfo, __VA_ARGS__)
#define RCTLogTrace(...) _RCTLog(RCTLogLevelTrace, __VA_ARGS__)
#define RCTLogInfo(...) _RCTLog(RCTLogLevelInfo, __VA_ARGS__)
#define RCTLogWarn(...) _RCTLog(RCTLogLevelWarning, __VA_ARGS__)
#define RCTLogError(...) _RCTLog(RCTLogLevelError, __VA_ARGS__)
I was wondering if there is something similar (in react native) for Android as well. I tried fishing through the react native code, but could not find any way to do it. I was wondering if anyone had to do it for Android.
Can someone please help me with this?
Maybe is too late for this, but you can use react-native-android-log (I'm the author).
Example:
import Log from 'react-native-android-log'
// Set the default level (optional)
Log.setLevel(__DEV__ ? Log.VERBOSE : Log.WARN)
...
Log.v('Verbose message') // no output in release builds
Log.w('Debugging')
...and see the output in the console through adb:
$ adb logcat -s App:V
...or in the "OUTPUT" panel of VS Code.
Please take a look at the README of the package, there you will find how to configure and use it.
I was using some external libraries/APIs which I was unable to debug my problems with the standard logging.
Putting
window.LOG_LEVEL = 'DEBUG'
at the top of App.js printed the external logs, allowing me to debug my problem. I think there are other log levels you can pass to the window as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With