[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [ernie/master] Don't break while logging without having imported any data yet.



Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Thu, 15 Apr 2010 10:17:08 +0200
Subject: Don't break while logging without having imported any data yet.
Commit: d532e1707fe99caab729f7ae9c885285f81bbd5f

---
 src/ConsensusStatsFileHandler.java |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/ConsensusStatsFileHandler.java b/src/ConsensusStatsFileHandler.java
index 46227af..1d7a0fe 100644
--- a/src/ConsensusStatsFileHandler.java
+++ b/src/ConsensusStatsFileHandler.java
@@ -477,13 +477,25 @@ public class ConsensusStatsFileHandler {
     /* Set modification flags to false again. */
     this.relaysRawModified = this.bridgesRawModified = false;
 
-    logger.info("Finished writing statistics on relay consensuses and "
-        + "bridge statuses to disk.\nAdded " + this.relayResultsAdded
-        + " relay consensus(es) and " + this.bridgeResultsAdded
-        + " bridge status(es) in this execution.\nLast known relay "
-        + "consensus was published "+ this.relaysRaw.lastKey() + ", last "
-        + "known bridge status was published " + this.bridgesRaw.lastKey()
-        + ".");
+    /* Write stats. */
+    StringBuilder dumpStats = new StringBuilder("Finished writing "
+        + "statistics on relay consensuses and bridge statuses to disk.\n"
+        + "Added " + this.relayResultsAdded + " relay consensus(es) and "
+        + this.bridgeResultsAdded + " bridge status(es) in this "
+        + "execution.");
+    if (this.relaysRaw.isEmpty()) {
+      dumpStats.append("\nNo relay consensus known yet.");
+    } else {
+      dumpStats.append("\nLast known relay consensus was published "
+          + this.relaysRaw.lastKey() + ".");
+    }
+    if (this.bridgesRaw.isEmpty()) {
+      dumpStats.append("\nNo bridge status known yet.");
+    } else {
+      dumpStats.append("\nLast known bridge status was published "
+          + this.bridgesRaw.lastKey() + ".");
+    }
+    logger.info(dumpStats.toString());
   }
 }
 
-- 
1.6.5