Skip to content

Core Concepts

Lumber

Lumber is the static-style entry point.

Lumber.info("Ready")

Oak

Lumber.Oak is the extension point for custom logging backends.

class ConsoleOak : Lumber.Oak() {
    override fun isLoggable(tag: String?, level: Lumber.Level) = true

    override fun log(level: Lumber.Level, tag: String?, message: String, error: Throwable?) {
        println("[$level] ${tag ?: "-"} $message")
    }
}

The message already includes the throwable stack trace when an error is provided.

DebugOak

DebugOak is the built-in platform oak.

  • Android routes to android.util.Log
  • JVM prints colored lines to stdout
  • Apple prints colored lines to stdout
  • JS and WasmJS use the native console

Tagged facades

Lumber.tag(...) returns a lightweight facade that keeps the tag across calls.

val authLog = Lumber.tag("Auth")

authLog.info("Session created")
authLog.info("Session refreshed")

One-shot options

These values are consumed after the next log call:

  • quiet(...)
  • maxLogLength(...)
  • maxTagLength(...)

That behavior keeps temporary logging options local and predictable.

Forest

Lumber.plant(...), Lumber.uproot(...), and Lumber.uprootAll() manage the active oaks.

Lumber.plant(DebugOak())
Lumber.uprootAll()

Message formatting

Messages support %s and %d placeholders. Arguments are inserted once; placeholder-like text inside an argument remains literal. Extra arguments are ignored. With no arguments, the template is unchanged; otherwise, too few arguments throw IllegalStateException. %d accepts Number values and renders null for other values.

Lumber.info("value=%s, count=%d", "%s", 2) // value=%s, count=2