-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLogger.java
100 lines (93 loc) · 1.87 KB
/
Logger.java
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
/**
* Write comma separated numbers and strings for a CSV file
*/
import java.io.*;
import java.util.Calendar;
public class Logger
{
PrintWriter writer, cwriter;
public void init () throws Exception
{
StringBuilder builder = new StringBuilder (G.LOG_PREFIX);
Calendar cal = Calendar.getInstance();
int i=cal.get(Calendar.DATE);
builder.append(i); builder.append("_");
i = cal.get(Calendar.MONTH);
builder.append((i+1)); builder.append("_");
i = cal.get(Calendar.YEAR);
builder.append(i); builder.append("_");
i = cal.get(Calendar.HOUR);
builder.append(i); builder.append("-");
i = cal.get(Calendar.MINUTE);
builder.append(i); builder.append("-");
i = cal.get(Calendar.SECOND);
builder.append(i);
String cumulativeFile = builder.toString()+"C"+G.LOG_SUFFIX;
builder.append(G.LOG_SUFFIX);
writer = new PrintWriter(builder.toString());
cwriter = new PrintWriter(cumulativeFile);
}
public void log (String str)
{
writer.write (str +",");
}
public void log (int num)
{
writer.write (num +",");
}
public void log (float num)
{
writer.write (num +",");
}
public void logln ()
{
writer.write ("\n");
}
public void logln (String str)
{
writer.write (str +"\n");
}
public void logn (int num)
{
writer.write (num +"\n");
}
public void logln (float num)
{
writer.write (num +"\n");
}
public void clog (String str)
{
cwriter.write (str +",");
}
public void clog (int num)
{
cwriter.write (num +",");
}
public void clog (float num)
{
cwriter.write (num +",");
}
public void clogln ()
{
cwriter.write ("\n");
}
public void clogln (String str)
{
cwriter.write (str +"\n");
}
public void clogn (int num)
{
cwriter.write (num +"\n");
}
public void clogln (float num)
{
cwriter.write (num +"\n");
}
public void close()
{
writer.flush();
writer.close();
cwriter.flush();
cwriter.close();
}
}