ConsoleSink

class ConsoleSink(logFormatter: LogEventFormatter = LogFormatters.default(false)) : LogSink(source)

A LogSink that writes log events to standard output using println.

Suitable for command-line tools, desktop apps, and server-side environments where platform-native logging (e.g. Logcat, NSLog) is not available or desired.

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

Example:

LoggerFactory.install(
LoggerConfig.Builder()
.addSink(ConsoleSink())
// or with a custom formatter
.addSink(ConsoleSink(LogFormatters.json(showEmoji = false)))
.build()
)

Constructors

Link copied to clipboard
constructor(logFormatter: LogEventFormatter = LogFormatters.default(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.