Log

object Log(source)

Simple logging API for quick, tag-based logging.

All calls are routed through LoggerFactory, so sinks, formatters, and level filtering configured via LoggerFactory.install apply equally to both APIs.

For structured logging with attributes and context, use Logger from LoggerFactory instead.

Usage:

// Direct logging with default tag
Log.i("App started")
Log.e("Error occurred", throwable = exception)

// With custom tag
Log.i("User logged in", tag = "Auth")

// Using class-based tag
class MyViewModel {
private val log = Log.withClassTag<MyViewModel>()

fun doSomething() {
log.d("Doing something")
}
}

// Using custom tag wrapper
val log = Log.withTag("NetworkModule")
log.d("Connecting to server")

Functions

Link copied to clipboard
fun d(message: String, tag: String = defaultTag)

Logs a DEBUG message.

Link copied to clipboard
fun e(message: String, tag: String = defaultTag, throwable: Throwable? = null)

Logs an ERROR message.

Link copied to clipboard
fun fatal(message: String, tag: String = defaultTag, throwable: Throwable? = null)

Logs a FATAL message and throws a RuntimeException after all sinks have been flushed.

Link copied to clipboard
fun i(message: String, tag: String = defaultTag)

Logs an INFO message.

Link copied to clipboard

Sets the default tag used for all Log calls that do not specify an explicit tag. Call this once during application initialization.

Link copied to clipboard
fun v(message: String, tag: String = defaultTag)

Logs a VERBOSE message.

Link copied to clipboard
fun w(message: String, tag: String = defaultTag, throwable: Throwable? = null)

Logs a WARN message.

Link copied to clipboard
inline fun <T> withClassTag(): LogWrapper

Returns a LogWrapper whose tag is derived from the simple name of class T.

Link copied to clipboard

Returns a LogWrapper that uses tag on every call.