explaingit

jakewharton/timber

10,819KotlinAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

Timber is a lightweight Android logging library that automatically tags log messages with the calling class name and routes them to one or more destinations through a pluggable Tree pattern, no manual tag strings needed.

Mindmap

mindmap
  root((repo))
    What It Does
      Android logging wrapper
      Auto-tagging
      Pluggable destinations
    Key Concepts
      Trees
      DebugTree
      Custom Trees
    Features
      Automatic class tags
      Lint rules
      Format string checks
    Integration
      Maven Central
      Kotlin and Java
    Audience
      Android developers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add structured, auto-tagged logging to an Android app without writing or managing tag strings anywhere in the codebase.

USE CASE 2

Route production crash logs to a reporting service like Firebase Crashlytics by writing a custom Tree alongside the debug logger.

USE CASE 3

Catch logging mistakes at compile time, mismatched format string arguments or raw Log calls, using Timber's built-in lint rules.

Tech stack

KotlinJava

Getting it running

Difficulty · easy Time to first run · 5min
Free to use in any project including commercial, with attribution required and no copyleft restrictions.

In plain English

Timber is a logging library for Android apps, written by Jake Wharton, a well-known Android developer. Android has a built-in logging system called Log, and Timber is a thin wrapper around it that adds a few practical improvements. The main convenience Timber offers is automatic tagging. When you write a log statement in Android code, you normally have to supply a tag string identifying where the log came from, and managing these tags manually across a large codebase is tedious. Timber figures out the calling class name automatically and uses it as the tag, so you can write log calls without thinking about that detail. The library is built around a concept called Trees. A Tree is an object that decides what to do with each log message. You install one or more Trees when your app starts up. The default one included, called DebugTree, prints to Android's standard log output. If you wanted logs to also go to a crash reporting service in production, you would write a custom Tree that sends them there and install both Trees at startup. Logging calls anywhere in your app then reach all installed Trees automatically. Timber also ships with built-in lint rules, which are static analysis checks that run while you compile. They catch common mistakes such as passing the wrong number of arguments for a format string, using log tags that are too long for Android's limit, calling Android's raw Log class directly instead of Timber, or wrapping log messages with String.format when Timber already handles formatting. It is installed as a standard Android library dependency through Maven Central. The library is licensed under the Apache License 2.0.

Copy-paste prompts

Prompt 1
Show me how to set up Timber in an Android app, the Application class init, the DebugTree for debug builds, and how I'd call it from a fragment.
Prompt 2
I want logs in my Android app to go to both the console in debug mode and to Firebase Crashlytics in production. Write me a custom Timber Tree for Crashlytics and show how to install both trees.
Prompt 3
What lint rules does Timber ship with? Give me examples of the mistakes they catch and how Timber expects you to write those log calls instead.
Prompt 4
How does Timber compare to Android's built-in Log class? Show me the same log call written both ways and explain what Timber adds.
Open on GitHub → Explain another repo

← jakewharton on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.