diff --git a/Cargo.toml b/Cargo.toml index 5553915..05e8ec3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "breez-sdk-rn-generator" -version = "0.0.13" +version = "0.0.14" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/gen_kotlin/templates/module.kt b/src/gen_kotlin/templates/module.kt index a5196e9..7febfa9 100644 --- a/src/gen_kotlin/templates/module.kt +++ b/src/gen_kotlin/templates/module.kt @@ -62,12 +62,13 @@ class BreezSDKModule(reactContext: ReactApplicationContext) : ReactContextBaseJa {% endif -%} {%- endfor %} @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/src/gen_swift/templates/extern.m b/src/gen_swift/templates/extern.m index 42da3af..2c2e8b7 100644 --- a/src/gen_swift/templates/extern.m +++ b/src/gen_swift/templates/extern.m @@ -8,7 +8,8 @@ @interface RCT_EXTERN_MODULE(RNBreezSDK, RCTEventEmitter) {% endif %} {%- endfor %} RCT_EXTERN_METHOD( - setLogStream: (RCTPromiseResolveBlock)resolve + setLogStream: (NSString*)filterLevel + resolve: (RCTPromiseResolveBlock)resolve reject: (RCTPromiseRejectBlock)reject ) diff --git a/src/gen_swift/templates/module.swift b/src/gen_swift/templates/module.swift index b124279..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(_ 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()) + 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) diff --git a/src/gen_typescript/templates/Helpers.ts b/src/gen_typescript/templates/Helpers.ts index 4717775..85c64df 100644 --- a/src/gen_typescript/templates/Helpers.ts +++ b/src/gen_typescript/templates/Helpers.ts @@ -10,11 +10,11 @@ export const connect = async (req: ConnectRequest, listener: EventListener): Pro return subscription } -export const setLogStream = async (logStream: LogStream): Promise => { +export const setLogStream = async (logStream: LogStream, filterLevel?: LevelFilter): Promise => { const subscription = BreezSDKEmitter.addListener("breezSdkLog", logStream) try { - await BreezSDK.setLogStream() + await BreezSDK.setLogStream(filterLevel) } catch {} return subscription