StructuredTree

class StructuredTree(sinks: List<Sink>, globalFields: Map<String, Any?> = emptyMap()) : Timber.Tree

A Timber.Tree that supports structured logging.

Merges per-log fields from StructuredTimber, thread-local context from StructuredLog, and globalFields, then delegates to each registered Sink. This class is safe to use from multiple threads concurrently; field merging is performed on the calling thread using thread-local state.

Timber.plant(
StructuredTree(
sinks = listOf(LogcatSink(), CrashlyticsSink()),
globalFields = mapOf("app_version" to BuildConfig.VERSION_NAME)
)
)

Since

1.0.0

Parameters

sinks

Log destinations. Must not be empty.

globalFields

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

Constructors

Link copied to clipboard
constructor(sinks: List<Sink>, globalFields: Map<String, Any?> = emptyMap())

Functions

Link copied to clipboard
open fun d(t: Throwable?)
open fun d(message: String?, vararg args: Any?)
open fun d(t: Throwable?, message: String?, vararg args: Any?)
Link copied to clipboard
open fun e(t: Throwable?)
open fun e(message: String?, vararg args: Any?)
open fun e(t: Throwable?, message: String?, vararg args: Any?)
Link copied to clipboard
open fun i(t: Throwable?)
open fun i(message: String?, vararg args: Any?)
open fun i(t: Throwable?, message: String?, vararg args: Any?)
Link copied to clipboard
open fun log(priority: Int, t: Throwable?)
open fun log(priority: Int, message: String?, vararg args: Any?)
open fun log(priority: Int, t: Throwable?, message: String?, vararg args: Any?)
Link copied to clipboard
open fun v(t: Throwable?)
open fun v(message: String?, vararg args: Any?)
open fun v(t: Throwable?, message: String?, vararg args: Any?)
Link copied to clipboard
open fun w(t: Throwable?)
open fun w(message: String?, vararg args: Any?)
open fun w(t: Throwable?, message: String?, vararg args: Any?)
Link copied to clipboard
open fun wtf(t: Throwable?)
open fun wtf(message: String?, vararg args: Any?)
open fun wtf(t: Throwable?, message: String?, vararg args: Any?)