Flow
fun <C : Log.Category> Flow(flow: MutableSharedFlow<Log.Event<C>> = MutableSharedFlow(
extraBufferCapacity = 64,
onBufferOverflow = BufferOverflow.DROP_OLDEST,
)): Log.SharedLogFlow<C>
A sink that emits log Events into a SharedFlow.
Example
val flow = MutableSharedFlow<Event<Log.Category>>()
.also { flow ->
flow
.onEach { db.save(it.category.name, it.message) }
.launchIn(scope)
}
// Forward logs from both libraries to the database.
// Note that if libraries log using different Category types,
// they are flattened to the base `Log.Category`.
val m = LibraryManager() // logger: Log.Sink<LibraryComponent>
m.logger = Log.Sink.Flow(flow)
val m2 = AnotherLibraryManager() // logger: Log.Sink<AnotherLibraryComponent>
m2.logger = Log.Sink.Flow(flow)Content copied to clipboard
Return
A SharedLogFlow that emits Events.
Parameters
flow
An optional MutableSharedFlow to emit Events into. If not provided, a new MutableSharedFlow is created. The flow has a default buffer capacity of 64, and drops the oldest events on overflow.