-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRuntimeLog.java
More file actions
77 lines (62 loc) · 1.85 KB
/
RuntimeLog.java
File metadata and controls
77 lines (62 loc) · 1.85 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
/**
*
* A simple globalLog that can be used to record a trace of
* an instrumented program.
*
* The output can be used for grading and debugging.
*
* This code is used in the class project in COP5556 Programming Language Principles
* at the University of Florida, Spring 2018.
*
* This software is solely for the educational benefit of students
* enrolled in the course during the Spring 2018 semester.
*
* This software, and any software derived from it, may not be shared with others or posted to public web sites,
* either during the course or afterwards.
*
* @Beverly A. Sanders, 2018
*/
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;
}
}