DefaultLogSink

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

A LogSink that writes to each platform's native log output:

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

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

  • JS / Wasm - the browser or Node.js console

  • JVM / Linux / Windows - standard output

This is the sink installed automatically when LoggerFactory.install is never called, and the recommended one during development: every level appears where developers already look.

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

A throwable is rendered once, by the platform channel itself (on JS as the error object), so logFormatter receives the event without it. As a result LogFormatters.json output from this sink has no error field; use ConsoleSink or RemoteLogSink for pure JSON lines.

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 before a FATAL log throws.