From 130bb38cc60b6b07919d79653dbe6d7afd89a10b Mon Sep 17 00:00:00 2001 From: Erdem Yerebasmaz Date: Fri, 22 Mar 2024 14:45:30 +0300 Subject: [PATCH 1/3] Add optional filter level param to set log stream --- src/gen_typescript/templates/Helpers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 7ff53bb8cfcdb34fb3eed329fa4da06e6ae3741a Mon Sep 17 00:00:00 2001 From: Erdem Yerebasmaz Date: Fri, 22 Mar 2024 17:43:51 +0300 Subject: [PATCH 2/3] Update implementation on native generators --- src/gen_kotlin/templates/module.kt | 5 +++-- src/gen_swift/templates/extern.m | 3 ++- src/gen_swift/templates/module.swift | 10 +++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) 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) From 430a73ab27a70e2dfdb70fac7797d213ba6138aa Mon Sep 17 00:00:00 2001 From: Erdem Yerebasmaz Date: Mon, 25 Mar 2024 09:59:02 +0300 Subject: [PATCH 3/3] Bump Cargo.toml version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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