diff --git a/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKModule.kt b/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKModule.kt index f0a1db330..e220180a0 100644 --- a/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKModule.kt +++ b/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKModule.kt @@ -159,12 +159,16 @@ class BreezSDKModule(reactContext: ReactApplicationContext) : ReactContextBaseJa } @ReactMethod - fun setLogStream(promise: Promise) { + fun setLogStream( + filterLevel: String?, + promise: Promise, + ) { executor.execute { try { val emitter = reactApplicationContext.getJSModule(RCTDeviceEventEmitter::class.java) + val levelFilter = filterLevel?.let { asLevelFilter(filterLevel) } - setLogStream(BreezSDKLogStream(emitter)) + setLogStream(BreezSDKLogStream(emitter), levelFilter) promise.resolve(readableMapOf("status" to "ok")) } catch (e: Exception) { e.printStackTrace() diff --git a/libs/sdk-react-native/example/App.js b/libs/sdk-react-native/example/App.js index a2185738a..a5b0f67bb 100644 --- a/libs/sdk-react-native/example/App.js +++ b/libs/sdk-react-native/example/App.js @@ -71,7 +71,7 @@ const App = () => { const asyncFn = async () => { try { - logSubscription = await setLogStream(logHandler) + logSubscription = await setLogStream(logHandler, null) let mnemonic = await getSecureItem(MNEMONIC_STORE) diff --git a/libs/sdk-react-native/ios/RNBreezSDK.m b/libs/sdk-react-native/ios/RNBreezSDK.m index 6fa525445..3aea9a40b 100644 --- a/libs/sdk-react-native/ios/RNBreezSDK.m +++ b/libs/sdk-react-native/ios/RNBreezSDK.m @@ -42,7 +42,8 @@ @interface RCT_EXTERN_MODULE(RNBreezSDK, RCTEventEmitter) ) RCT_EXTERN_METHOD( - setLogStream: (RCTPromiseResolveBlock)resolve + setLogStream: (NSString*)filterLevel + resolve: (RCTPromiseResolveBlock)resolve reject: (RCTPromiseRejectBlock)reject ) diff --git a/libs/sdk-react-native/ios/RNBreezSDK.swift b/libs/sdk-react-native/ios/RNBreezSDK.swift index a36b69a1e..5acedd931 100644 --- a/libs/sdk-react-native/ios/RNBreezSDK.swift +++ b/libs/sdk-react-native/ios/RNBreezSDK.swift @@ -130,10 +130,14 @@ class RNBreezSDK: RCTEventEmitter { } } - @objc(setLogStream:reject:) - func setLogStream(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { + @objc(setLogStream:resolve:reject:) + func setLogStream(_ filterLevel: String?, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { do { - try BreezSDK.setLogStream(logStream: BreezSDKLogStream()) + var levelFilter: LevelFilter? = nil + if filterLevel != nil { + levelFilter = try BreezSDKMapper.asLevelFilter(levelFilter: filterLevel!) + } + try BreezSDK.setLogStream(logStream: BreezSDKLogStream(), filterLevel: levelFilter) resolve(["status": "ok"]) } catch let err { rejectErr(err: err, reject: reject)