Skip to content

Commit

Permalink
Apply filter level changes to Flutter plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
erdemyerebasmaz committed Mar 23, 2024
1 parent 492f08c commit 18a4b02
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class SdkLogListener : LogStream {
private val logEvents: SharedFlow<LogEntry> = _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) =
Expand Down

0 comments on commit 18a4b02

Please sign in to comment.