-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.pde
38 lines (34 loc) · 1.57 KB
/
log.pde
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
final String TIMESTAMP = ""+year()+nf(month(), 2)+nf(day(), 2)+"_"+nf(hour(), 2)+nf(minute(), 2)+nf(second(), 2);
// %yyyy-%mm-%dd %hh:%mm:%ss
LOGFILE log;
void logexit() {
log.log("exiting...");
saveStrings("log.log", log.logstrings);
exit();
}
String CURRENT_TIMESTAMP() {
return ""+year()+nf(month(), 2)+nf(day(), 2)+"_"+nf(hour(), 2)+nf(minute(), 2)+nf(second(), 2);
}
String TIMESTAMP_DETAIL() {
return ""+year()+"/"+nf(month(), 2)+"/"+nf(day(), 2)+"\u0009"+nf(hour(), 2)+":"+nf(minute(), 2)+":"+nf(second(), 2);
}
class LOGFILE {
String[] logstrings = {};
public void log(String what) {
logstrings = append(logstrings, "["+TIMESTAMP_DETAIL()+"\u0009frame "+realt+" \u0009\u0009"+millis()+" ms]\u0009"+" DEBUG:\u0009\u0009"+what);
}
public void error(String what, boolean critical) {
logstrings = append(logstrings, "["+TIMESTAMP_DETAIL()+"\u0009frame "+realt+" \u0009\u0009"+millis()+" ms]\u0009"+" ERROR:\u0009\u0009"+what);
showError(what, critical);
}
public void warn(String what) {
logstrings = append(logstrings, "["+TIMESTAMP_DETAIL()+"\u0009frame "+realt+" \u0009\u0009"+millis()+" ms]\u0009"+" WARNING:\u0009"+what);
showWarning(what);
}
public void created(String what) {
logstrings = append(logstrings, "["+TIMESTAMP_DETAIL()+"\u0009frame "+realt+" \u0009\u0009"+millis()+" ms]\u0009"+" CREATED:\u0009"+what);
}
public void loaded(String what) {
logstrings = append(logstrings, "["+TIMESTAMP_DETAIL()+"\u0009frame "+realt+" \u0009\u0009"+millis()+" ms]\u0009"+" LOADED:\u0009"+what);
}
}