Logging Sink
class LoggingSink(val maxLevel: TraceLevel = TraceLevel.Dispatch, log: (String) -> Unit) : TraceSink(source)
Writes each event as one human-readable line (its toString) to log. Never throws: an Exception from log is swallowed so logging cannot break dispatch.
Example:
val sink = LoggingSink(TraceLevel.Coroutine) { line -> println(line) }Content copied to clipboard
Thread-safety is that of log: emit may be called concurrently from many threads.
Requires opting in to ExperimentalStructuredCoroutines.
Parameters
max Level
highest TraceLevel this sink accepts.
log
receives one line per event; must be cheap and non-blocking.