Yuta HIGUCHI

human readable time representation for toString

Example:
 LinkEvent{time=2014-10-28T23:24:23.461, ...

Change-Id: I439cea488afd97dfa4f1c1e5770f2e2d7b64d321
......@@ -36,6 +36,10 @@
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
</dependencies>
</project>
......
......@@ -17,6 +17,8 @@ package org.onlab.onos.event;
import static com.google.common.base.MoreObjects.toStringHelper;
import org.joda.time.LocalDateTime;
/**
* Base event implementation.
*/
......@@ -67,8 +69,11 @@ public class AbstractEvent<T extends Enum, S extends Object> implements Event<T,
@Override
public String toString() {
return toStringHelper(this).add("time", time).add("type", type())
.add("subject", subject()).toString();
return toStringHelper(this)
.add("time", new LocalDateTime(time))
.add("type", type())
.add("subject", subject())
.toString();
}
}
......
......@@ -15,6 +15,7 @@
*/
package org.onlab.onos.mastership;
import org.joda.time.LocalDateTime;
import org.onlab.onos.cluster.RoleInfo;
import org.onlab.onos.event.AbstractEvent;
import org.onlab.onos.net.DeviceId;
......@@ -83,7 +84,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("time", time())
.add("time", new LocalDateTime(time()))
.add("type", type())
.add("subject", subject())
.add("roleInfo", roleInfo)
......
......@@ -15,6 +15,7 @@
*/
package org.onlab.onos.net.device;
import org.joda.time.LocalDateTime;
import org.onlab.onos.event.AbstractEvent;
import org.onlab.onos.net.Device;
import org.onlab.onos.net.Port;
......@@ -131,7 +132,11 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> {
if (port == null) {
return super.toString();
}
return toStringHelper(this).add("time", time()).add("type", type())
.add("subject", subject()).add("port", port).toString();
return toStringHelper(this)
.add("time", new LocalDateTime(time()))
.add("type", type())
.add("subject", subject())
.add("port", port)
.toString();
}
}
......
......@@ -32,6 +32,8 @@
<bundle>mvn:io.netty/netty-transport-native-epoll/4.0.23.Final</bundle>
<bundle>mvn:commons-pool/commons-pool/1.6</bundle>
<bundle>mvn:joda-time/joda-time/2.5</bundle>
<bundle>mvn:com.hazelcast/hazelcast/3.3.2</bundle>
<bundle>mvn:io.dropwizard.metrics/metrics-core/3.1.0</bundle>
<bundle>mvn:io.dropwizard.metrics/metrics-json/3.1.0</bundle>
......
......@@ -319,6 +319,11 @@
<artifactId>netty-transport-native-epoll</artifactId>
<version>${netty4.version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
</dependencyManagement>
......