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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
/* */ 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
/* */ {
/* 77 */ private static PrintStream out = null;
/* */
/* */
/* 80 */ 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";
/* */
/* */
/* 98 */ private static String mailReason = "error encountered";
/* 99 */ 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()
/* */ {
/* 110 */ baseName = IniFile.gamma().getIniString("logfile", "");
/* 111 */ if (baseName.length() == 0) {
/* 112 */ return;
/* */ }
/* 114 */ baseName = Gamma.earlyURLUnalias("home:" + baseName);
/* */
/* */
/* 117 */ File f = new File(baseName + ".open");
/* 118 */ if (f.isFile())
/* */ {
/* */
/* 121 */ if (scanFileForException(f)) {
/* 122 */ mailReason = "logfile not closed--probable crash";
/* 123 */ 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";
/* 124 */ File mf = new File(baseName + ".mail");
/* 125 */ f.renameTo(mf);
/* 126 */ mf = null;
/* */ } else {
/* 128 */ f.delete();
/* */ }
/* */ }
/* */
/* 132 */ f = new File(baseName);
/* 133 */ if (f.isFile()) {
/* 134 */ f.delete();
/* */ }
/* 136 */ f = null;
/* */
/* */
/* 139 */ FileOutputStream FOout = null;
/* */ try {
/* 141 */ FOout = new FileOutputStream(baseName + ".open");
/* */ } catch (IOException e) {
/* 143 */ System.out.println("Error opening logfile \"" + baseName + "\"");
/* 144 */ return;
/* */ }
/* */
/* 147 */ out = new PrintStream(new BufferedOutputStream(FOout), true);
/* */
/* */
/* 150 */ System.setOut(out);
/* 151 */ System.setErr(out);
/* */
/* */
/* */
/* 155 */ out.println("Logfile of " +
/* 156 */ DateFormat.getDateTimeInstance().format(new Date()));
/* 157 */ out.println("Gamma " +
/* 158 */ Std.getVersion() +
/* 159 */ ":" +
/* 160 */ Std.getJavaVersion() +
/* 161 */ ", build " +
/* 162 */ Std.getBuildInfo() +
/* 163 */ " of " +
/* 164 */ DateFormat.getDateTimeInstance().format(
/* 165 */ new Date(Std.getBuildDate())));
/* 166 */ out.println("system info---------------------------------");
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* 174 */ SystemInfo.Record(out);
/* */
/* 176 */ out.println("worlds.ini----------------------------------");
/* */
/* */
/* */ try
/* */ {
/* 181 */ String from = System.getProperty("file.encoding");
/* 182 */ InputStream in = new FileInputStream("worlds.ini");
/* 183 */ BufferedReader ini = new BufferedReader(new InputStreamReader(in,
/* 184 */ from));
/* */
/* 186 */ for (String s = ini.readLine(); s != null; s = ini.readLine())
/* 187 */ out.println(s);
/* 188 */ ini.close();
/* */ }
/* */ catch (IOException localIOException1) {}
/* 191 */ out.println("--------------------------------------------");
/* */ }
/* */
/* */
/* */ public static void close()
/* */ {
/* 197 */ if (out != null) {
/* 198 */ out.println("Logfile closed.");
/* 199 */ out.close();
/* */ }
/* */
/* */
/* */
/* 204 */ File f = new File(baseName + ".open");
/* 205 */ if (scanFileForException(f)) {
/* 206 */ File mf = new File(baseName + ".mail");
/* 207 */ f.renameTo(mf);
/* 208 */ mf = null;
/* */ } else {
/* 210 */ File nf = new File(baseName);
/* 211 */ if (f.isFile())
/* 212 */ f.renameTo(nf);
/* 213 */ nf = null;
/* */ }
/* 215 */ f = null;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static void mailLogIfPresent(String server)
/* */ {
/* 225 */ DialogReceiver rcvr = new DialogReceiver() {
/* */ public void dialogDone(Object who, boolean confirmed) {
/* 227 */ LogMailDialog dlg = (LogMailDialog)who;
/* 228 */ File f = new File(LogFile.baseName + ".mail");
/* 229 */ if (f.isFile()) {
/* 230 */ if (confirmed) {
/* 231 */ LogFile.sendCrashMail(LogFile.this, f, LogFile.mailReason, dlg.getComment());
/* */ } else {
/* 233 */ f.delete();
/* */ }
/* */ }
/* */ }
/* 237 */ };
/* 238 */ File f = new File(baseName + ".mail");
/* 239 */ if (f.isFile())
/* */ {
/* 241 */ String tag = "The last time you ran " + Std.getProductName() +
/* 242 */ mailTag;
/* 243 */ if (IniFile.gamma().getIniString("LASTCHATNAME", "").length() == 0) {
/* 244 */ new LogMailDialog(rcvr, tag + "Also, please include your email address.\n");
/* */ } else {
/* 246 */ new LogMailDialog(rcvr, tag);
/* */ }
/* */ }
/* */ }
/* */
/* */ private static void sendCrashMail(String server, File logFile, String tagLine, String comment)
/* */ {
/* 253 */ MailMessage msg = new LogFileMailMessage(server, logFile);
/* */ try {
/* 255 */ if (tagLine != null)
/* 256 */ msg.appendBody(" (" + tagLine + ")");
/* 257 */ msg.appendBody(".\n\n");
/* 258 */ if (comment != null) {
/* 259 */ msg.appendBody("The user reports:\n");
/* 260 */ msg.appendParagraphs(comment);
/* 261 */ msg.appendBody("\n\n");
/* */ }
/* 263 */ msg.appendBody("The log file reads:\n\n");
/* */
/* 265 */ String from = System.getProperty("file.encoding");
/* 266 */ InputStream in = new FileInputStream(logFile);
/* 267 */ BufferedReader log = new BufferedReader(new InputStreamReader(in,
/* 268 */ from));
/* */
/* */
/* 271 */ long fl = logFile.length();
/* 272 */ if (fl > 64000L) {
/* 273 */ int lc = 0;
/* 274 */ long cc = 0L;
/* */
/* 276 */ for (String s = log.readLine(); (s != null) && (lc < 2048); s = log
/* 277 */ .readLine()) {
/* 278 */ msg.appendBody(s + "\n");
/* 279 */ lc++;
/* 280 */ cc += s.length();
/* */ }
/* */
/* 283 */ msg.appendBody("-------------------------------------...\n");
/* 284 */ msg.appendBody(" Log file too long; skipping center\n");
/* 285 */ msg.appendBody("...-------------------------------------\n");
/* */
/* 287 */ log.skip(fl - (cc + 16030L));
/* 288 */ log.readLine();
/* 289 */ for (String s = log.readLine(); s != null; s = log.readLine())
/* 290 */ msg.appendBody(s + "\n");
/* */ } else {
/* 292 */ for (String s = log.readLine(); s != null; s = log.readLine())
/* 293 */ msg.appendBody(s + "\n");
/* */ }
/* 295 */ log.close();
/* */ } catch (IOException ex) {
/* 297 */ System.out.println("Error writing logfile to mail note: " + ex);
/* */ }
/* 299 */ msg.send();
/* */ }
/* */
/* */ private static boolean scanFileForException(File logFile)
/* */ {
/* */ try
/* */ {
/* 306 */ String from = System.getProperty("file.encoding");
/* 307 */ InputStream in = new FileInputStream(logFile);
/* 308 */ BufferedReader log = new BufferedReader(new InputStreamReader(in,
/* 309 */ from));
/* 310 */ for (String s = log.readLine(); s != null; s = log.readLine()) {
/* 311 */ if ((s.indexOf("\tat NET.worlds") != -1) ||
/* 312 */ (s.indexOf("\tat java.lang") != -1) ||
/* 313 */ (s.indexOf("\tat sun.awt") != -1)) {
/* 314 */ log.close();
/* 315 */ return true;
/* */ }
/* */ }
/* 318 */ log.close();
/* */ }
/* */ catch (IOException localIOException) {}
/* */
/* 322 */ return false;
/* */ }
/* */ }
/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\LogFile.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
|