From 3b616b894770f5d9155c0ff193f22068cabdad57 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Thu, 26 Jul 2018 18:40:08 +0100 Subject: [PATCH] toString() methods in some events --- core/src/main/groovy/com/muwire/core/Event.groovy | 5 +++++ core/src/main/groovy/com/muwire/core/EventBus.groovy | 2 +- .../groovy/com/muwire/core/connection/ConnectionEvent.groovy | 5 +++++ .../main/groovy/com/muwire/core/connection/Endpoint.groovy | 5 +++++ .../com/muwire/core/hostcache/HostDiscoveredEvent.groovy | 5 +++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/core/src/main/groovy/com/muwire/core/Event.groovy b/core/src/main/groovy/com/muwire/core/Event.groovy index 4a9c0e94..511ad2da 100644 --- a/core/src/main/groovy/com/muwire/core/Event.groovy +++ b/core/src/main/groovy/com/muwire/core/Event.groovy @@ -12,4 +12,9 @@ class Event { seqNo = SEQ_NO.getAndIncrement() timestamp = System.currentTimeMillis() } + + @Override + public String toString() { + "seqNo $seqNo timestamp $timestamp" + } } diff --git a/core/src/main/groovy/com/muwire/core/EventBus.groovy b/core/src/main/groovy/com/muwire/core/EventBus.groovy index e63f368c..7cdf8c10 100644 --- a/core/src/main/groovy/com/muwire/core/EventBus.groovy +++ b/core/src/main/groovy/com/muwire/core/EventBus.groovy @@ -23,7 +23,7 @@ class EventBus { } private void publishInternal(Event e) { - log.fine "publishing event of type ${e.getClass().getSimpleName()} seqNo ${e.seqNo} timestamp ${e.timestamp}" + log.fine "publishing event $e" def currentHandlers final def clazz = e.getClass() synchronized(this) { diff --git a/core/src/main/groovy/com/muwire/core/connection/ConnectionEvent.groovy b/core/src/main/groovy/com/muwire/core/connection/ConnectionEvent.groovy index 5e1305cf..ac57d9c9 100644 --- a/core/src/main/groovy/com/muwire/core/connection/ConnectionEvent.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/ConnectionEvent.groovy @@ -10,5 +10,10 @@ class ConnectionEvent extends Event { boolean incoming Boolean leaf // can be null if uknown ConnectionAttemptStatus status + + @Override + public String toString() { + "ConnectionEvent ${super.toString()} endpoint: $endpoint incoming: $incoming leaf : $leaf status : $status" + } } diff --git a/core/src/main/groovy/com/muwire/core/connection/Endpoint.groovy b/core/src/main/groovy/com/muwire/core/connection/Endpoint.groovy index 9b841b1b..5e4db6b2 100644 --- a/core/src/main/groovy/com/muwire/core/connection/Endpoint.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/Endpoint.groovy @@ -32,4 +32,9 @@ class Endpoint implements Closeable { try {outputStream.close()} catch (Exception ignore) {} } } + + @Override + public String toString() { + "destination: ${destination.toBase32()}" + } } diff --git a/core/src/main/groovy/com/muwire/core/hostcache/HostDiscoveredEvent.groovy b/core/src/main/groovy/com/muwire/core/hostcache/HostDiscoveredEvent.groovy index 4f3348ca..bfd72001 100644 --- a/core/src/main/groovy/com/muwire/core/hostcache/HostDiscoveredEvent.groovy +++ b/core/src/main/groovy/com/muwire/core/hostcache/HostDiscoveredEvent.groovy @@ -7,4 +7,9 @@ import net.i2p.data.Destination class HostDiscoveredEvent extends Event { Destination destination + + @Override + public String toString() { + "HostDiscoveredEvent ${super.toString()} destination:${destination.toBase32()}" + } }