blob: 7a2c70d260ff8533c7e19039d16d19d9d1dd4051 (
plain)
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
|
package cz.crcs.ectester.reader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
/**
* @author Petr Svenda petr@svenda.com
* @author Jan Jancar johny@neuromancer.sk
*/
public class DirtyLogger {
FileWriter log;
boolean systemOut;
public DirtyLogger(String filePath) throws IOException {
this(filePath, true);
}
public DirtyLogger(String filePath, boolean systemOut) throws IOException {
if (filePath != null)
this.log = new FileWriter(filePath);
this.systemOut = systemOut;
}
public void println() {
print("\n");
}
public void println(String logLine) {
logLine += "\n";
print(logLine);
}
public void print(String logLine) {
if (systemOut) {
System.out.print(logLine);
}
if (log != null) {
try {
log.write(logLine);
} catch (IOException ignored) {
}
}
}
void flush() {
try {
if (log != null) log.flush();
} catch (IOException ignored) {
}
}
void close() throws IOException {
if (log != null) log.close();
}
}
|