How can I write to console.log from Java in React Native

Viewed 2696

I'm building a React Native native module (aka 'bridge') for iOS and Android and need to log to the JS console in native code (Objective C and Java). This is done easily in iOS using RCTLog but I can't figure out how to do it in Java.

I tried Log.i but those messages aren't forwarded to Javascript.

The only thing I can think of at this point is to emit a JS event from the Java module and have a handler on the JS side just call console.log with the message but that's a pretty roundabout way of doing it.

I would expect to be able to do something like this.getReactApplicationContext().log("see me in the JS console") but no dice. Anyone know how to do this?

1 Answers
Related