From d6aeb1748e52b0495e27d1607137ec33a3c9ab74 Mon Sep 17 00:00:00 2001 From: Erdem Yerebasmaz Date: Fri, 22 Mar 2024 22:28:05 +0300 Subject: [PATCH] Address feedback --- src/gen_kotlin/templates/module.kt | 4 ++-- src/gen_swift/templates/module.swift | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gen_kotlin/templates/module.kt b/src/gen_kotlin/templates/module.kt index 92734f9..7febfa9 100644 --- a/src/gen_kotlin/templates/module.kt +++ b/src/gen_kotlin/templates/module.kt @@ -62,11 +62,11 @@ class BreezSDKModule(reactContext: ReactApplicationContext) : ReactContextBaseJa {% endif -%} {%- endfor %} @ReactMethod - fun setLogStream(filterLevel: String, promise: Promise) { + fun setLogStream(filterLevel: String?, promise: Promise) { executor.execute { try { val emitter = reactApplicationContext.getJSModule(RCTDeviceEventEmitter::class.java) - val levelFilter = asLevelFilter(filterLevel); + val levelFilter = filterLevel?.let { asLevelFilter(filterLevel) } setLogStream(BreezSDKLogStream(emitter), levelFilter) promise.resolve(readableMapOf("status" to "ok")) diff --git a/src/gen_swift/templates/module.swift b/src/gen_swift/templates/module.swift index 332cd9e..ed64862 100644 --- a/src/gen_swift/templates/module.swift +++ b/src/gen_swift/templates/module.swift @@ -72,10 +72,14 @@ class RNBreezSDK: RCTEventEmitter { {% include "TopLevelFunctionTemplate.swift" %} {% endif -%} {%- endfor %} - @objc(setLogStream:reject:) - func setLogStream(_ filterLevel: LevelFilter = nil, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void { + @objc(setLogStream:resolve:reject:) + func setLogStream(_ filterLevel: String?, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void { do { - try BreezSDK.setLogStream(logStream: BreezSDKLogStream(), filterLevel: filterLevel) + 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)