blob: ffae71c40d0666ea4c79d0d4b2372b0d4f3bb38f (
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
|
package gtPlusPlus.core.util;
import java.io.*;
import java.util.Date;
public class LoggingUtils {
public static boolean logCurrentSystemTime(final String message) {
final Date date = new Date(System.currentTimeMillis());
try {
LoggingUtils.profileLog(message + " | " + date.toString());
return true;
}
catch (final Throwable r) {
return false;
}
}
public static void profileLog(final Object o) {
try {
String content;
final File file = new File("GregtechTimingsTC.txt");
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
final FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
final BufferedWriter bw = new BufferedWriter(fw);
bw.write("============================================================");
bw.write(System.lineSeparator());
bw.close();
}
if (o instanceof String) {
content = (String) o;
}
else {
content = o.toString();
}
final FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
final BufferedWriter bw = new BufferedWriter(fw);
bw.write(content);
bw.write(System.lineSeparator());
bw.close();
System.out.println("Data Logged.");
}
catch (final IOException e) {
System.out.println("Data logging failed.");
}
}
}
|