|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package org.qedeq.kernel.log; |
|
19 |
| |
|
20 |
| import java.io.PrintStream; |
|
21 |
| import java.util.Date; |
|
22 |
| import java.text.SimpleDateFormat; |
|
23 |
| |
|
24 |
| import org.qedeq.kernel.bo.module.ModuleProperties; |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| public class DefaultModuleEventListener implements ModuleEventListener { |
|
33 |
| |
|
34 |
| |
|
35 |
| private PrintStream out = System.out; |
|
36 |
| |
|
37 |
| |
|
38 |
| private static final SimpleDateFormat FORMATTER |
|
39 |
| = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss,SSS"); |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
0
| public DefaultModuleEventListener() {
|
|
45 |
0
| this(System.out);
|
|
46 |
| } |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
| |
|
53 |
0
| public DefaultModuleEventListener(final PrintStream stream) {
|
|
54 |
0
| this.out = stream;
|
|
55 |
| } |
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
0
| public final void setPrintStream(final PrintStream stream) {
|
|
63 |
0
| this.out = stream;
|
|
64 |
| } |
|
65 |
| |
|
66 |
0
| public void addModule(final ModuleProperties prop) {
|
|
67 |
0
| out.println(getTimestamp() + " Module added. "
|
|
68 |
| + prop.getStateDescription() + "\n\t" + prop.getAddress()); |
|
69 |
| } |
|
70 |
| |
|
71 |
0
| public void stateChanged(final ModuleProperties prop) {
|
|
72 |
0
| out.println(getTimestamp() + " Module state changed. "
|
|
73 |
| + prop.getStateDescription() + "\n\t" + prop.getAddress()); |
|
74 |
| } |
|
75 |
| |
|
76 |
0
| public void removeModule(final ModuleProperties prop) {
|
|
77 |
0
| out.println(getTimestamp() + " Module removed. "
|
|
78 |
| + prop.getStateDescription() + "\n\t" + prop.getAddress()); |
|
79 |
| } |
|
80 |
| |
|
81 |
0
| private static final String getTimestamp() {
|
|
82 |
0
| return FORMATTER.format(new Date()).toString();
|
|
83 |
| } |
|
84 |
| |
|
85 |
| } |