human readable time representation for toString
Example: LinkEvent{time=2014-10-28T23:24:23.461, ... Change-Id: I439cea488afd97dfa4f1c1e5770f2e2d7b64d321
Showing
6 changed files
with
27 additions
and
5 deletions
... | @@ -36,6 +36,10 @@ | ... | @@ -36,6 +36,10 @@ |
36 | <groupId>com.google.guava</groupId> | 36 | <groupId>com.google.guava</groupId> |
37 | <artifactId>guava-testlib</artifactId> | 37 | <artifactId>guava-testlib</artifactId> |
38 | </dependency> | 38 | </dependency> |
39 | + <dependency> | ||
40 | + <groupId>joda-time</groupId> | ||
41 | + <artifactId>joda-time</artifactId> | ||
42 | + </dependency> | ||
39 | </dependencies> | 43 | </dependencies> |
40 | 44 | ||
41 | </project> | 45 | </project> | ... | ... |
... | @@ -17,6 +17,8 @@ package org.onlab.onos.event; | ... | @@ -17,6 +17,8 @@ package org.onlab.onos.event; |
17 | 17 | ||
18 | import static com.google.common.base.MoreObjects.toStringHelper; | 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
19 | 19 | ||
20 | +import org.joda.time.LocalDateTime; | ||
21 | + | ||
20 | /** | 22 | /** |
21 | * Base event implementation. | 23 | * Base event implementation. |
22 | */ | 24 | */ |
... | @@ -67,8 +69,11 @@ public class AbstractEvent<T extends Enum, S extends Object> implements Event<T, | ... | @@ -67,8 +69,11 @@ public class AbstractEvent<T extends Enum, S extends Object> implements Event<T, |
67 | 69 | ||
68 | @Override | 70 | @Override |
69 | public String toString() { | 71 | public String toString() { |
70 | - return toStringHelper(this).add("time", time).add("type", type()) | 72 | + return toStringHelper(this) |
71 | - .add("subject", subject()).toString(); | 73 | + .add("time", new LocalDateTime(time)) |
74 | + .add("type", type()) | ||
75 | + .add("subject", subject()) | ||
76 | + .toString(); | ||
72 | } | 77 | } |
73 | 78 | ||
74 | } | 79 | } | ... | ... |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onlab.onos.mastership; | 16 | package org.onlab.onos.mastership; |
17 | 17 | ||
18 | +import org.joda.time.LocalDateTime; | ||
18 | import org.onlab.onos.cluster.RoleInfo; | 19 | import org.onlab.onos.cluster.RoleInfo; |
19 | import org.onlab.onos.event.AbstractEvent; | 20 | import org.onlab.onos.event.AbstractEvent; |
20 | import org.onlab.onos.net.DeviceId; | 21 | import org.onlab.onos.net.DeviceId; |
... | @@ -83,7 +84,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI | ... | @@ -83,7 +84,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI |
83 | @Override | 84 | @Override |
84 | public String toString() { | 85 | public String toString() { |
85 | return MoreObjects.toStringHelper(getClass()) | 86 | return MoreObjects.toStringHelper(getClass()) |
86 | - .add("time", time()) | 87 | + .add("time", new LocalDateTime(time())) |
87 | .add("type", type()) | 88 | .add("type", type()) |
88 | .add("subject", subject()) | 89 | .add("subject", subject()) |
89 | .add("roleInfo", roleInfo) | 90 | .add("roleInfo", roleInfo) | ... | ... |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onlab.onos.net.device; | 16 | package org.onlab.onos.net.device; |
17 | 17 | ||
18 | +import org.joda.time.LocalDateTime; | ||
18 | import org.onlab.onos.event.AbstractEvent; | 19 | import org.onlab.onos.event.AbstractEvent; |
19 | import org.onlab.onos.net.Device; | 20 | import org.onlab.onos.net.Device; |
20 | import org.onlab.onos.net.Port; | 21 | import org.onlab.onos.net.Port; |
... | @@ -131,7 +132,11 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> { | ... | @@ -131,7 +132,11 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> { |
131 | if (port == null) { | 132 | if (port == null) { |
132 | return super.toString(); | 133 | return super.toString(); |
133 | } | 134 | } |
134 | - return toStringHelper(this).add("time", time()).add("type", type()) | 135 | + return toStringHelper(this) |
135 | - .add("subject", subject()).add("port", port).toString(); | 136 | + .add("time", new LocalDateTime(time())) |
137 | + .add("type", type()) | ||
138 | + .add("subject", subject()) | ||
139 | + .add("port", port) | ||
140 | + .toString(); | ||
136 | } | 141 | } |
137 | } | 142 | } | ... | ... |
... | @@ -32,6 +32,8 @@ | ... | @@ -32,6 +32,8 @@ |
32 | <bundle>mvn:io.netty/netty-transport-native-epoll/4.0.23.Final</bundle> | 32 | <bundle>mvn:io.netty/netty-transport-native-epoll/4.0.23.Final</bundle> |
33 | <bundle>mvn:commons-pool/commons-pool/1.6</bundle> | 33 | <bundle>mvn:commons-pool/commons-pool/1.6</bundle> |
34 | 34 | ||
35 | + <bundle>mvn:joda-time/joda-time/2.5</bundle> | ||
36 | + | ||
35 | <bundle>mvn:com.hazelcast/hazelcast/3.3.2</bundle> | 37 | <bundle>mvn:com.hazelcast/hazelcast/3.3.2</bundle> |
36 | <bundle>mvn:io.dropwizard.metrics/metrics-core/3.1.0</bundle> | 38 | <bundle>mvn:io.dropwizard.metrics/metrics-core/3.1.0</bundle> |
37 | <bundle>mvn:io.dropwizard.metrics/metrics-json/3.1.0</bundle> | 39 | <bundle>mvn:io.dropwizard.metrics/metrics-json/3.1.0</bundle> | ... | ... |
... | @@ -319,6 +319,11 @@ | ... | @@ -319,6 +319,11 @@ |
319 | <artifactId>netty-transport-native-epoll</artifactId> | 319 | <artifactId>netty-transport-native-epoll</artifactId> |
320 | <version>${netty4.version}</version> | 320 | <version>${netty4.version}</version> |
321 | </dependency> | 321 | </dependency> |
322 | + <dependency> | ||
323 | + <groupId>joda-time</groupId> | ||
324 | + <artifactId>joda-time</artifactId> | ||
325 | + <version>2.5</version> | ||
326 | + </dependency> | ||
322 | </dependencies> | 327 | </dependencies> |
323 | </dependencyManagement> | 328 | </dependencyManagement> |
324 | 329 | ... | ... |
-
Please register or login to post a comment