LoggingSink

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) }

Thread-safety is that of log: emit may be called concurrently from many threads.

Requires opting in to ExperimentalStructuredCoroutines.

Parameters

maxLevel

highest TraceLevel this sink accepts.

log

receives one line per event; must be cheap and non-blocking.

See also

Constructors

Link copied to clipboard
constructor(maxLevel: TraceLevel = TraceLevel.Dispatch, log: (String) -> Unit)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun emit(event: TraceEvent)

Receives one event. See the contract in the type documentation.

Link copied to clipboard
open override fun isEnabled(level: TraceLevel): Boolean

Whether this sink wants events of level. Defaults to true for every level.