-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCosmicLogHandler.java
More file actions
43 lines (38 loc) · 1.2 KB
/
CosmicLogHandler.java
File metadata and controls
43 lines (38 loc) · 1.2 KB
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
package singularity.logging;
import singularity.events.server.ServerLogTextEvent;
import java.util.logging.LogRecord;
import java.util.logging.StreamHandler;
import java.util.logging.Level;
public class CosmicLogHandler extends StreamHandler {
public CosmicLogHandler() {
// Set output to System.out by default
super.setOutputStream(System.out);
}
@Override
public synchronized void publish(LogRecord record) {
Level level = record.getLevel();
LogIntent intent = null;
switch (level.getName()) {
case "FINE":
intent = LogIntent.DEBUG;
break;
case "INFO":
intent = LogIntent.INFO;
break;
case "WARNING":
intent = LogIntent.WARNING;
break;
case "SEVERE":
intent = LogIntent.SEVERE;
break;
default:
intent = LogIntent.OTHER;
break;
}
// Create and fire the event
ServerLogTextEvent event = new ServerLogTextEvent(record.getMessage(), intent).fire();
if (event.isCancelled()) {
return;
}
}
}