Last active
April 13, 2016 00:05
-
-
Save ChrisRenke/4039d2cf8756ca8826bab8aa48da79f0 to your computer and use it in GitHub Desktop.
Thread-Aware Tree for Timber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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