fix: wire log level setters into commons logger across Kotlin, Flutter, RN, and Web (#1059)

SH
4d ago
+681-0

Closes #1059
Follow-up from #1049.

Summary

Wired setLogLevel, configureLogging, setDebugMode, and setMinLogLevel across Kotlin, Flutter, React Native, and Web SDKs into the RACommons C++ logger (rac_logger_set_min_level), matching the Swift pattern established in #1049. Previously, these setters only mutated host-side configuration state and left the C++ commons logging threshold unchanged.

Changes by SDK

  1. Commons / Native Bridges:

    • JNI (core/src/jni/runanywhere_commons_jni.cpp): Added JNI exports Java_com_runanywhere_sdk_native_bridge_RunAnywhereBridge_racLoggerSetMinLevel and Java_com_runanywhere_sdk_native_bridge_RunAnywhereBridge_racLoggerGetMinLevel.
    • WASM (bindings/web/wasm/CMakeLists.txt): Exported _rac_logger_set_min_level and _rac_logger_get_min_level.
    • Flutter FFI (bindings/flutter/packages/runanywhere/lib/native/native_functions.dart & dart_bridge.dart): Added bindings for rac_logger_set_min_level and rac_logger_get_min_level.
    • React Native Nitro (bindings/react-native/packages/core): Exposed loggerSetMinLevel and loggerGetMinLevel in the RunAnywhereCore spec and C++ hybrid implementation (HybridRunAnywhereCore.cpp).
  2. Log Level Parity & Synchronization:

    • Kotlin:
      • Added LogLevel.toRacLogLevel(): Int and racLogLevelToProto(Int): LogLevel mappings in SDKLogger.kt.
      • Hooked Logging.configure() and Logging.setMinLogLevel() to forward to RunAnywhereBridge.racLoggerSetMinLevel().
      • Added automatic sync on native library load in RunAnywhereBridge.kt.
    • Flutter:
      • Added LogLevelRacMapping extension and racLogLevelToProto helper in sdk_logger.dart.
      • Hooked SDKLoggerConfig.shared.configure() and setMinLogLevel() to call DartBridge.setCommonsMinLogLevel().
    • React Native:
      • Added syncCommonsLogLevel in LoggingManager.ts during configure() and setMinLogLevel().
      • Hooked SDK initialization in RunAnywhere.ts to sync the commons logger level upon native load.
    • Web:
      • Added _rac_logger_set_min_level and _rac_logger_get_min_level to EmscriptenRunanywhereModule interface.
      • Added toRacLogLevel and racLogLevelToProto in SDKLogger.ts.
      • Added decoupling sink setCommonsLogLevelSink in SDKLogger.ts wired to setCommonsMinLogLevel in EmscriptenModule.ts to avoid circular imports.
      • Registered modules automatically receive the configured minimum level on registerWasmModule().
  3. Tests:

    • Added unit tests per SDK covering bidirectional mapping and synchronization with teardown restoration:
      • Kotlin: LoggingParityTest.kt
      • Flutter: logging_parity_test.dart
      • React Native: LoggingParity.test.ts
      • Web: LoggingParity.test.ts (all 61 test files / 284 tests passing)

Checklist

  • Code follows project style guidelines
  • Bidirectional log level mappings implemented per SDK
  • Tested commons logger synchronization with prior level restored in teardown

Summary by cubic

Wires setLogLevel, configureLogging, setDebugMode, and setMinLogLevel into the RACommons C++ logger across Kotlin, Flutter, React Native, and Web. Previously these setters only updated host-side configuration and left the C++ logging threshold unchanged; now they call rac_logger_set_min_level through the JNI, WASM, FFI, and Nitro bridges to match the Swift behavior from #1049.

  • Adds bidirectional mappings between the proto LogLevel enum and the C-ABI rac_log_level_t integers in each SDK.
  • Syncs the configured minimum level when native libraries or WASM modules load, so registrations inherit the current setting.
  • Newly registered Web modules receive the active minimum level via a decoupling sink in EmscriptenModule.ts.
  • Adds unit tests per SDK covering mappings and synchronization, with teardown restoring prior levels.

Summary by CodeRabbit

  • New Features
    • Logging configuration now stays in sync with the native logger across Flutter, Kotlin, React Native, and Web SDKs.
    • You can set and retrieve the native logger’s minimum severity level through the supported platform interfaces.
    • Log levels map consistently across SDKs, with unrecognized values falling back to INFO.
  • Tests
    • Added coverage for log-level mapping and synchronization between SDK logging settings and native logging levels.