forked from xathis/AI-Challenge-2011-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogger.java
52 lines (41 loc) · 1.11 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.io.*;
public class Logger {
public static boolean ENABLED = Strategy.DEBUG;
private static int i = 0;
public static int MISC = 1 << i++;
public static int PREC = 1 << i++;
public static int PREC_GROUP = 1 << i++;
public static int TIME = 1 << i++;
public static int TIMEOUT = 1 << i++;
public static int PREC_TIME = 1 << i++;
public static int FLAGS = MISC;
protected PrintStream logStream = null;
protected String logFileName = null;
protected long cnt = 0;
public Logger(String logFileName) {
if (!ENABLED) return;
this.logFileName = logFileName;
resetLogStream();
}
public void print(String s, int flag) {
if (!ENABLED || (flag & FLAGS) == 0) return;
this.logStream.print(s);
}
public void print(String s) {
print(s, MISC);
}
public void println(String s, int flag) {
if (!ENABLED || (flag & FLAGS) == 0) return;
this.logStream.println(s);
}
public void println(String s) {
println(s, MISC);
}
protected void resetLogStream() {
try {
this.logStream = new PrintStream(new File(logFileName));
} catch (Exception e) {
e.printStackTrace();
}
}
}