Skip to content

Instantly share code, notes, and snippets.

@ChrisRenke
Last active April 13, 2016 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisRenke/4039d2cf8756ca8826bab8aa48da79f0 to your computer and use it in GitHub Desktop.
Save ChrisRenke/4039d2cf8756ca8826bab8aa48da79f0 to your computer and use it in GitHub Desktop.
Thread-Aware Tree for Timber
import timber.log.Timber;
/** Tree that logs the current thread pre-pended. Useful for multi-thread Rx'y things. */
public class ThreadAwareDebugTree extends Timber.DebugTree {
@Override protected boolean isLoggable(int priority) {
return super.isLoggable(priority);
}
@Override protected void log(int priority, String tag, String message, Throwable t) {
if (tag != null) {
String threadName = Thread.currentThread().getName();
tag = "<" + threadName + "> " + tag;
}
super.log(priority, tag, message, t);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment