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) = diff --git a/libs/sdk-flutter/lib/breez_sdk.dart b/libs/sdk-flutter/lib/breez_sdk.dart index 5f7cf555e..8f6da3f9d 100644 --- a/libs/sdk-flutter/lib/breez_sdk.dart +++ b/libs/sdk-flutter/lib/breez_sdk.dart @@ -25,9 +25,9 @@ class BreezSDK { Stream get paymentResultStream => _paymentResultStream.stream; /// Initializes SDK events & log streams - void initialize() { + void initialize({LevelFilter? filterLevel}) { _initializeEventsStream(); - _initializeLogStream(); + _initializeLogStream(filterLevel: filterLevel); } /// Listen to BreezEvent's(new block, invoice paid, synced) @@ -62,7 +62,7 @@ class BreezSDK { } /// Listen to node logs - void _initializeLogStream() { + void _initializeLogStream({LevelFilter? filterLevel}) { if (defaultTargetPlatform == TargetPlatform.android) { const EventChannel('breez_sdk_node_logs') .receiveBroadcastStream() @@ -72,7 +72,7 @@ class BreezSDK { onError: (e) => _logStreamController.addError(e), ); } else { - _lnToolkit.breezLogStream().listen((logEntry) { + _lnToolkit.breezLogStream(filterLevel: filterLevel).listen((logEntry) { _logStreamController.add(logEntry); }, onError: (e) { _logStreamController.addError(e);