DefaultLogSink

class DefaultLogSink(logFormatter: LogEventFormatter = LogFormatters.pretty(false)) : LogSink(source)

A LogSink that delegates to the platform's native logging mechanism.

On each platform this maps to the most appropriate native output:

  • Android - android.util.Log (visible in Logcat)

  • iOS / macOS - NSLog (visible in Xcode console)

  • JVM - java.util.logging.Logger

  • JS / Wasm - console.log / console.error etc.

  • Linux / Windows - println to standard output

This is the recommended sink for most applications because it integrates with the platform's existing log infrastructure (filtering, log levels, crash reporting hooks, etc.).

The output format is controlled by logFormatter. Defaults to LogFormatters.pretty without emoji.

Example:

LoggerFactory.install(
LoggerConfig.Builder()
.addSink(DefaultLogSink())
// or with a custom formatter
.addSink(DefaultLogSink(LogFormatters.compact(showEmoji = true)))
.build()
)

Constructors

Link copied to clipboard
constructor(logFormatter: LogEventFormatter = LogFormatters.pretty(false))

Functions

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

Emits a log event to the output destination.

Link copied to clipboard
open fun flush()

Flushes any buffered log events. Called automatically when a FATAL log occurs or during shutdown.