-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebug.java
More file actions
145 lines (116 loc) · 3.74 KB
/
Copy pathDebug.java
File metadata and controls
145 lines (116 loc) · 3.74 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package com.smiths;
import org.andengine.util.constants.Constants;
import android.util.Log;
/**
* (c) 2010 Nicolas Gramlich
* (c) 2011 Zynga Inc.
*
* @author Nicolas Gramlich
* @since 13:29:16 - 08.03.2010
*/
public class Debug implements Constants {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
private static String sDebugTag = DEBUGTAG;
private static DebugLevel sDebugLevel = DebugLevel.VERBOSE;
// ===========================================================
// Constructors
// ===========================================================
// ===========================================================
// Getter & Setter
// ===========================================================
public static String getDebugTag() {
return Debug.sDebugTag;
}
public static void setDebugTag(final String pDebugTag) {
Debug.sDebugTag = pDebugTag;
}
public static DebugLevel getDebugLevel() {
return Debug.sDebugLevel;
}
public static void setDebugLevel(final DebugLevel pDebugLevel) {
if(pDebugLevel == null) {
throw new IllegalArgumentException("pDebugLevel must not be null!");
}
Debug.sDebugLevel = pDebugLevel;
}
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
// ===========================================================
// Methods
// ===========================================================
public static void v(final String pMessage) {
Debug.v(pMessage, null);
}
public static void v(final String pMessage, final Throwable pThrowable) {
if(sDebugLevel.isSameOrLessThan(DebugLevel.VERBOSE)) {
Log.v(sDebugTag, pMessage, pThrowable);
}
}
public static void d(final String pMessage) {
Debug.d(pMessage, null);
}
public static void d(final String pMessage, final Throwable pThrowable) {
if(sDebugLevel.isSameOrLessThan(DebugLevel.DEBUG)) {
Log.d(sDebugTag, pMessage, pThrowable);
}
}
public static void i(final String pMessage) {
Debug.i(pMessage, null);
}
public static void i(final String pMessage, final Throwable pThrowable) {
if(sDebugLevel.isSameOrLessThan(DebugLevel.INFO)) {
Log.i(sDebugTag, pMessage, pThrowable);
}
}
public static void w(final String pMessage) {
Debug.w(pMessage, null);
}
public static void w(final Throwable pThrowable) {
Debug.w("", pThrowable);
}
public static void w(final String pMessage, final Throwable pThrowable) {
if(sDebugLevel.isSameOrLessThan(DebugLevel.WARNING)) {
if(pThrowable == null) {
Log.w(sDebugTag, pMessage, new Exception());
} else {
Log.w(sDebugTag, pMessage, pThrowable);
}
}
}
public static void e(final String pMessage) {
Debug.e(pMessage, null);
}
public static void e(final Throwable pThrowable) {
Debug.e(sDebugTag, pThrowable);
}
public static void e(final String pMessage, final Throwable pThrowable) {
if(sDebugLevel.isSameOrLessThan(DebugLevel.ERROR)) {
if(pThrowable == null) {
Log.e(sDebugTag, pMessage, new Exception());
} else {
Log.e(sDebugTag, pMessage, pThrowable);
}
}
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
public static enum DebugLevel implements Comparable<DebugLevel> {
NONE,
ERROR,
WARNING,
INFO,
DEBUG,
VERBOSE;
public static DebugLevel ALL = DebugLevel.VERBOSE;
private boolean isSameOrLessThan(final DebugLevel pDebugLevel) {
return this.compareTo(pDebugLevel) >= 0;
}
}
}