From 18a4b02d033129b2310b973482f12e068e7dc349 Mon Sep 17 00:00:00 2001 From: Erdem Yerebasmaz Date: Sat, 23 Mar 2024 16:35:53 +0300 Subject: [PATCH] Apply filter level changes to Flutter plugin --- .../src/main/kotlin/com/breez/breez_sdk/BreezSDKPlugin.kt | 2 +- .../src/main/kotlin/com/breez/breez_sdk/SdkLogInitializer.kt | 5 +++-- .../src/main/kotlin/com/breez/breez_sdk/SdkLogListener.kt | 4 +--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libs/sdk-flutter/android/src/main/kotlin/com/breez/breez_sdk/BreezSDKPlugin.kt b/libs/sdk-flutter/android/src/main/kotlin/com/breez/breez_sdk/BreezSDKPlugin.kt index e4f0e5972..06717fd4c 100644 --- a/libs/sdk-flutter/android/src/main/kotlin/com/breez/breez_sdk/BreezSDKPlugin.kt +++ b/libs/sdk-flutter/android/src/main/kotlin/com/breez/breez_sdk/BreezSDKPlugin.kt @@ -22,7 +22,7 @@ class BreezSDKPlugin : FlutterPlugin, MethodCallHandler, EventChannel.StreamHand channel.setMethodCallHandler(this) eventChannel = EventChannel(flutterPluginBinding.binaryMessenger, "breez_sdk_node_logs") - val nodeLogStream = SdkLogInitializer.initializeNodeLogStream() + val nodeLogStream = SdkLogInitializer.initializeNodeLogStream(null) nodeLogStream.subscribe(scope) { l: LogEntry -> val data = mapOf("level" to l.level, "line" to l.line) eventSink?.success(data) diff --git a/libs/sdk-flutter/android/src/main/kotlin/com/breez/breez_sdk/SdkLogInitializer.kt b/libs/sdk-flutter/android/src/main/kotlin/com/breez/breez_sdk/SdkLogInitializer.kt index 35caa33cc..8c59faa85 100644 --- a/libs/sdk-flutter/android/src/main/kotlin/com/breez/breez_sdk/SdkLogInitializer.kt +++ b/libs/sdk-flutter/android/src/main/kotlin/com/breez/breez_sdk/SdkLogInitializer.kt @@ -1,16 +1,17 @@ package com.breez.breez_sdk import breez_sdk.setLogStream +import breez_sdk.LevelFilter import kotlinx.coroutines.CoroutineScope object SdkLogInitializer { private var nodeLogStream: SdkLogListener? = null - fun initializeNodeLogStream(): SdkLogListener { + fun initializeNodeLogStream(filterLevel: LevelFilter?): SdkLogListener { if (nodeLogStream == null) { try { nodeLogStream = SdkLogListener() - setLogStream(nodeLogStream!!) + setLogStream(nodeLogStream!!, filterLevel) } catch (e: Throwable) { // Reset nodeLogStream if setting log stream fails e.printStackTrace() diff --git a/libs/sdk-flutter/android/src/main/kotlin/com/breez/breez_sdk/SdkLogListener.kt b/libs/sdk-flutter/android/src/main/kotlin/com/breez/breez_sdk/SdkLogListener.kt index 4430b3317..f6acf8831 100644 --- a/libs/sdk-flutter/android/src/main/kotlin/com/breez/breez_sdk/SdkLogListener.kt +++ b/libs/sdk-flutter/android/src/main/kotlin/com/breez/breez_sdk/SdkLogListener.kt @@ -19,9 +19,7 @@ class SdkLogListener : LogStream { private val logEvents: SharedFlow = _logEvents.asSharedFlow() override fun log(l: LogEntry) { - scope.launch { - _logEvents.emit(l) - } + scope.launch { _logEvents.emit(l) } } fun subscribe(scope: CoroutineScope, block: suspend (LogEntry) -> Unit) =