-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogUtils.java
71 lines (57 loc) · 1.97 KB
/
LogUtils.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
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
package discoverylab.util.logging;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* LogUtils
* @author Irvin Steve Cardenas
*
* Logging utility class allows developer to log information, warning and errors
*/
public class LogUtils {
// private final static Logger LOGGER = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); Java Utils Logger = No Bueno
private static Logger logger = LoggerFactory.getLogger(LogUtils.class);
private static final String LOG_PREFIX = "discoverylab";
private static final int LOG_PREFIX_LENGTH = LOG_PREFIX.length();
private static final int MAX_LOG_TAG_LENGTH = 23;
public static String makeLogTag(String str) {
if(str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH){
return LOG_PREFIX + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH);
}
return LOG_PREFIX + str;
}
public static String makeLogTag(Class cls) {
return makeLogTag(cls.getSimpleName());
}
public static void LOGI(final String tag, String message) {
// logger.info(tag, message);
logger = LoggerFactory.getLogger(tag);
logger.info(message);
}
public static void LOGI(final String tag, String message, Throwable cause) {
// logger.info(tag, message, cause);
logger = LoggerFactory.getLogger(tag);
logger.info(message);
}
public static void LOGW(final String tag, String message) {
// logger.warn(tag, message);
logger = LoggerFactory.getLogger(tag);
logger.info(message);
}
public static void LOGW(final String tag, String message, Throwable cause) {
// logger.warn(tag, message, cause);
logger = LoggerFactory.getLogger(tag);
logger.info(message);
}
public static void LOGE(final String tag, String message){
// logger.error(tag, message);
logger = LoggerFactory.getLogger(tag);
logger.info(message);
}
public static void LEGE(final String tag, String message, Throwable cause){
// logger.error(tag, message, cause);
logger = LoggerFactory.getLogger(tag);
logger.info(message);
}
private LogUtils() {
}
}