-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathCommonLog.java
More file actions
95 lines (80 loc) · 2.28 KB
/
CommonLog.java
File metadata and controls
95 lines (80 loc) · 2.28 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package common.base.utils;
import common.base.BuildConfig;
/**
* 日志输出
* <br/>
* 2015年12月23日-上午11:41:07
* @author lifei
*/
public final class CommonLog {
// public final static boolean ISDEBUG = BuildConfig.DEBUG;
public static boolean ISDEBUG = BuildConfig.DEBUG;
public static void logEnable(boolean toEnable) {
ISDEBUG = toEnable;
}
public static void w(String tag, String content) {
if (ISDEBUG) {
android.util.Log.w(tag, content);
}
}
public static void w(final String tag, Object... objs) {
if (ISDEBUG) {
android.util.Log.w(tag, getInfo(objs));
}
}
public static void i(String tag, String content) {
if (ISDEBUG) {
android.util.Log.i(tag, content);
}
}
public static void i(final String tag, Object... objs) {
if (ISDEBUG) {
android.util.Log.i(tag, getInfo(objs));
}
}
public static void d(String tag, String content) {
if (ISDEBUG) {
android.util.Log.d(tag, content);
}
}
public static void d(final String tag, Object... objs) {
if (ISDEBUG) {
android.util.Log.d(tag, getInfo(objs));
}
}
public static void e(String tag, String content) {
if (ISDEBUG) {
android.util.Log.e(tag, content);
}
}
public static void e(String tag, String content, Throwable e) {
if (ISDEBUG) {
android.util.Log.e(tag, content, e);
}
}
public static void e(final String tag, Object... objs) {
if (ISDEBUG) {
android.util.Log.e(tag, getInfo(objs));
}
}
private static String getInfo(Object... objs) {
if (objs == null) {
return "";
}
StringBuffer sb = new StringBuffer();
for (Object object : objs) {
sb.append(object);
}
return sb.toString();
}
public static void sysOut(Object msg) {
if (ISDEBUG) {
System.out.println(msg);
}
}
public static void sysErr(Object msg) {
if (ISDEBUG) {
System.err.println(msg);
}
}
}