init

fun init(vararg sinks: Sink, globalFields: Map<String, Any?> = emptyMap())

Initialize structured logging by planting a StructuredTree with the given sinks.

This method is idempotent: calling it again uproots the previous StructuredTree before planting a new one. Other Timber.Tree instances planted separately are not affected.

This is a convenience method that replaces the manual Timber.plant(StructuredTree(...)) call.

StructuredTimber.init(
LogcatSink(minPriority = Log.DEBUG),
CrashlyticsSink(minPriority = Log.WARN),
globalFields = mapOf("app_version" to BuildConfig.VERSION_NAME),
)

Since

2.1.0

Parameters

sinks

One or more Sink destinations for structured log entries.

globalFields

Attributes automatically attached to every log entry. Defaults to an empty map.

Throws