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