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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
package NET.worlds.console;
import NET.worlds.core.IniFile;
import NET.worlds.core.Std;
import NET.worlds.core.SystemInfo;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.text.DateFormat;
import java.util.Date;
public class LogFile {
private static PrintStream out = null;
private static String baseName = null;
private static final String tempSuffix = ".open";
private static final String mailSuffix = ".mail";
private static final String noCloseTag = ", it terminated unexpectedly.\nPlease fill in the box below with an explanation of which\nfeatures you were exercising at the time, then click the\nReport button to automatically email the report to Worlds.\n";
private static final String errorFoundTag = ", it generated a debugging log.\nPlease fill in the box below with an explanation of anything\nunusual that occurred (if anything), then click the Report\nbutton to automatically email the report to Worlds.\n";
private static final String includeEmail = "Also, please include your email address.\n";
private static String mailReason = "error encountered";
private static String mailTag = ", it generated a debugging log.\nPlease fill in the box below with an explanation of anything\nunusual that occurred (if anything), then click the Report\nbutton to automatically email the report to Worlds.\n";
private static final String iniFile = "worlds.ini";
public static void open() {
baseName = IniFile.gamma().getIniString("logfile", "");
if (baseName.length() != 0) {
baseName = Gamma.earlyURLUnalias("home:" + baseName);
File f = new File(baseName + ".open");
if (f.isFile()) {
if (scanFileForException(f)) {
mailReason = "logfile not closed--probable crash";
mailTag = ", it terminated unexpectedly.\nPlease fill in the box below with an explanation of which\nfeatures you were exercising at the time, then click the\nReport button to automatically email the report to Worlds.\n";
File mf = new File(baseName + ".mail");
f.renameTo(mf);
mf = null;
} else {
f.delete();
}
}
f = new File(baseName);
if (f.isFile()) {
f.delete();
}
File var9 = null;
FileOutputStream FOout = null;
try {
FOout = new FileOutputStream(baseName + ".open");
} catch (IOException var6) {
System.out.println("Error opening logfile \"" + baseName + "\"");
return;
}
out = new PrintStream(new BufferedOutputStream(FOout), true);
System.setOut(out);
System.setErr(out);
out.println("Logfile of " + DateFormat.getDateTimeInstance().format(new Date()));
out.println(
"Gamma "
+ Std.getVersion()
+ ":"
+ "1890a40"
+ ", build "
+ Std.getBuildInfo()
+ " of "
+ DateFormat.getDateTimeInstance().format(new Date(Std.getBuildDate()))
);
out.println("system info---------------------------------");
SystemInfo.Record(out);
out.println("worlds.ini----------------------------------");
try {
String from = System.getProperty("file.encoding");
InputStream in = new FileInputStream("worlds.ini");
BufferedReader ini = new BufferedReader(new InputStreamReader(in, from));
for (String s = ini.readLine(); s != null; s = ini.readLine()) {
out.println(s);
}
ini.close();
} catch (IOException var7) {
}
out.println("--------------------------------------------");
}
}
public static void close() {
if (out != null) {
out.println("Logfile closed.");
out.close();
}
File f = new File(baseName + ".open");
if (scanFileForException(f)) {
File mf = new File(baseName + ".mail");
f.renameTo(mf);
mf = null;
} else {
File nf = new File(baseName);
if (f.isFile()) {
f.renameTo(nf);
}
nf = null;
}
File var2 = null;
}
public static void mailLogIfPresent(final String server) {
DialogReceiver rcvr = new DialogReceiver() {
@Override
public void dialogDone(Object who, boolean confirmed) {
LogMailDialog dlg = (LogMailDialog)who;
File f = new File(LogFile.baseName + ".mail");
if (f.isFile()) {
if (confirmed) {
LogFile.sendCrashMail(server, f, LogFile.mailReason, dlg.getComment());
} else {
f.delete();
}
}
}
};
File f = new File(baseName + ".mail");
if (f.isFile()) {
String tag = "The last time you ran " + Std.getProductName() + mailTag;
if (IniFile.gamma().getIniString("LASTCHATNAME", "").length() == 0) {
new LogMailDialog(rcvr, tag + "Also, please include your email address.\n");
} else {
new LogMailDialog(rcvr, tag);
}
}
}
private static void sendCrashMail(String server, File logFile, String tagLine, String comment) {
MailMessage msg = new LogFileMailMessage(server, logFile);
try {
if (tagLine != null) {
msg.appendBody(" (" + tagLine + ")");
}
msg.appendBody(".\n\n");
if (comment != null) {
msg.appendBody("The user reports:\n");
msg.appendParagraphs(comment);
msg.appendBody("\n\n");
}
msg.appendBody("The log file reads:\n\n");
String from = System.getProperty("file.encoding");
InputStream in = new FileInputStream(logFile);
BufferedReader log = new BufferedReader(new InputStreamReader(in, from));
long fl = logFile.length();
if (fl <= 64000L) {
for (String s = log.readLine(); s != null; s = log.readLine()) {
msg.appendBody(s + "\n");
}
} else {
int lc = 0;
long cc = 0L;
for (String s = log.readLine(); s != null && lc < 2048; s = log.readLine()) {
msg.appendBody(s + "\n");
lc++;
cc += s.length();
}
msg.appendBody("-------------------------------------...\n");
msg.appendBody(" Log file too long; skipping center\n");
msg.appendBody("...-------------------------------------\n");
log.skip(fl - (cc + 16030L));
log.readLine();
for (String s = log.readLine(); s != null; s = log.readLine()) {
msg.appendBody(s + "\n");
}
}
log.close();
} catch (IOException var14) {
System.out.println("Error writing logfile to mail note: " + var14);
}
msg.send();
}
private static boolean scanFileForException(File logFile) {
try {
String from = System.getProperty("file.encoding");
InputStream in = new FileInputStream(logFile);
BufferedReader log = new BufferedReader(new InputStreamReader(in, from));
for (String s = log.readLine(); s != null; s = log.readLine()) {
if (s.indexOf("\tat NET.worlds") != -1 || s.indexOf("\tat java.lang") != -1 || s.indexOf("\tat sun.awt") != -1) {
log.close();
return true;
}
}
log.close();
} catch (IOException var5) {
}
return false;
}
}
|