-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.java
More file actions
48 lines (39 loc) · 1.13 KB
/
Log.java
File metadata and controls
48 lines (39 loc) · 1.13 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
package javaassignment;
public class Log {
public static final int DEBUG_LEVEL = 3;
public static final int ERROR_LEVEL = 2;
public static final int INFO_LEVEL = 1;
public static final int NONE_LEVEL = 0;
public int debugLevel = INFO_LEVEL;// default: info level
public Log(){}
public Log(int debugLevel){
this.debugLevel = debugLevel;
}
public Log(String level){
if("DEBUG".equals(level)){
debugLevel = DEBUG_LEVEL;
}else if("ERROR".equals(level)){
debugLevel = DEBUG_LEVEL;
} else if ("NONE".equals(level)){
debugLevel = 0;
}
}
public void setDebugLevel(int debugLevel){
this.debugLevel = debugLevel;
}
public void info(String s){
if(debugLevel >= INFO_LEVEL){
System.out.println("INFO :"+ s);
}
}
public void error(String s){
if(debugLevel >= ERROR_LEVEL){
System.out.println("ERROR: "+s);
}
}
public void debug(String s){
if(debugLevel >= DEBUG_LEVEL){
System.out.println("DEBUG: "+s);
}
}
}