-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRuntimeLog.java
More file actions
58 lines (44 loc) · 1.23 KB
/
Copy pathRuntimeLog.java
File metadata and controls
58 lines (44 loc) · 1.23 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
package cop5556sp18;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
/**
*
* A simple globalLog that can be used to record a trace of
* an instrumented program.
*
* The output can be used for grading and debugging.
*
*/
public class RuntimeLog {
private StringBuffer sb;
public static RuntimeLog globalLog;
public static ArrayList<BufferedImage> globalImageLog;
public static void initLog() {
globalLog = new RuntimeLog();
globalLog.sb = new StringBuffer();
globalImageLog = new ArrayList<BufferedImage>();
}
public static void globalLogAddImage(BufferedImage image) {
if (globalImageLog != null) globalImageLog.add(image);
}
public static void addImage(BufferedImage image) {
globalImageLog.add(image);
}
public static void globalLogAddEntry(String entry){
if (globalLog != null) globalLog.addEntry(entry);
}
private void addEntry(String entry) {
sb.append(entry);
}
public static String getGlobalString() {
return (globalLog != null) ? globalLog.toString() : "";
}
@Override
public String toString() {
return sb.toString();
}
public static void resetLogToNull() {
globalLog = null;
globalImageLog = null;
}
}