diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/hermes/reactexecutor/OnLoad.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/hermes/reactexecutor/OnLoad.cpp index 3ce0267a2e5298..a27df522890367 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/hermes/reactexecutor/OnLoad.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/hermes/reactexecutor/OnLoad.cpp @@ -41,10 +41,7 @@ static ::hermes::vm::RuntimeConfig makeRuntimeConfig(jlong heapSizeMB) { } static void installBindings(jsi::Runtime& runtime) { - react::Logger androidLogger = - static_cast( - &reactAndroidLoggingHook); - react::bindNativeLogger(runtime, androidLogger); + react::bindNativeLogger(runtime, &reactAndroidLoggingHook); } class HermesExecutorHolder diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JSLogging.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/jni/JSLogging.cpp index 243b41f1af5754..34b2943831bd90 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JSLogging.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jni/JSLogging.cpp @@ -7,21 +7,16 @@ #include "JSLogging.h" -#include +#include namespace facebook::react { -void reactAndroidLoggingHook( - const std::string& message, - android_LogPriority logLevel) { - FBLOG_PRI(logLevel, "ReactNativeJS", "%s", message.c_str()); -} - void reactAndroidLoggingHook( const std::string& message, unsigned int logLevel) { - reactAndroidLoggingHook( - message, static_cast(logLevel + ANDROID_LOG_DEBUG)); + auto logPriority = + static_cast(logLevel + ANDROID_LOG_DEBUG); + __android_log_write(logPriority, "ReactNativeJS", message.c_str()); } } // namespace facebook::react diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JSLogging.h b/packages/react-native/ReactAndroid/src/main/jni/react/jni/JSLogging.h index d236f244519151..423e5896b64b63 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JSLogging.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jni/JSLogging.h @@ -7,14 +7,10 @@ #pragma once -#include #include namespace facebook::react { -void reactAndroidLoggingHook( - const std::string& message, - android_LogPriority logLevel); void reactAndroidLoggingHook(const std::string& message, unsigned int logLevel); } // namespace facebook::react diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jscexecutor/OnLoad.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/jscexecutor/OnLoad.cpp index f9a4649bca2a87..7cf63d7ceba292 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jscexecutor/OnLoad.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jscexecutor/OnLoad.cpp @@ -24,17 +24,13 @@ class JSCExecutorFactory : public JSExecutorFactory { std::unique_ptr createJSExecutor( std::shared_ptr delegate, std::shared_ptr jsQueue) override { - auto installBindings = [](jsi::Runtime& runtime) { - react::Logger androidLogger = - static_cast( - &reactAndroidLoggingHook); - react::bindNativeLogger(runtime, androidLogger); - }; return std::make_unique( jsc::makeJSCRuntime(), delegate, JSIExecutor::defaultTimeoutInvoker, - installBindings); + [](jsi::Runtime& runtime) { + react::bindNativeLogger(runtime, &reactAndroidLoggingHook); + }); } };