StructuredTimber
object StructuredTimber
Entry point for structured logging.
Wraps Timber to pass key-value fields alongside log messages. Fields are stored in a ThreadLocal and consumed by StructuredTree. Each thread maintains its own pending fields, so this object is safe to use from multiple threads concurrently without synchronization.
Call init to set up structured logging before using any logging methods:
StructuredTimber.init(
LogcatSink(minPriority = Log.DEBUG),
globalFields = mapOf("app_version" to BuildConfig.VERSION_NAME),
)Content copied to clipboard
Then log messages with structured fields:
StructuredTimber.d("Purchase completed",
"item_id" to "SKU-123",
"price" to 1980,
"currency" to "JPY"
)Content copied to clipboard
Alternatively, you can plant a StructuredTree manually via Timber.plant for advanced use cases.
Since
1.0.0