forked from nisrulz/android-tips-tricks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logger.java
31 lines (24 loc) · 632 Bytes
/
Logger.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package github.nisrulz.logger;
import android.util.Log;
public class Logger {
private final String TAG;
private final int priority;
public static Logger withTag(String tag) {
return new Logger(tag);
}
private Logger(String TAG) {
this.TAG = TAG;
this.priority = Log.DEBUG; // This could be ERROR / INFO / VERBOSE
}
public Logger log(String message) {
if (BuildConfig.DEBUG) {
Log.println(priority, TAG, message);
}
return this;
}
public void withCause(Exception cause) {
if (BuildConfig.DEBUG) {
Log.println(priority, TAG, Log.getStackTraceString(cause));
}
}
}