commit afebec01c101abb76af40d0d66a9fcbf88b026a5
Author: Karsten Loesing <karsten.loes...@gmx.net>
Date:   Mon Jul 7 17:58:51 2014 +0200

    Write problems with lock file to stderr, not stdout.
---
 bin/update.sh                          |    2 +-
 build.xml                              |    3 ++-
 src/org/torproject/onionoo/Logger.java |   18 ++++++++++++++++--
 src/org/torproject/onionoo/Main.java   |    4 ++--
 4 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/bin/update.sh b/bin/update.sh
index 71d54a8..9294f41 100755
--- a/bin/update.sh
+++ b/bin/update.sh
@@ -1,3 +1,3 @@
 #!/bin/bash
-ant run >> log
+ant run >> log && cat errors
 
diff --git a/build.xml b/build.xml
index 500204d..dccf374 100644
--- a/build.xml
+++ b/build.xml
@@ -93,7 +93,8 @@
   <target name="run" depends="compile">
     <java fork="true"
           maxmemory="4g"
-          classname="org.torproject.onionoo.Main">
+          classname="org.torproject.onionoo.Main"
+          error="errors">
       <classpath refid="classpath"/>
     </java>
   </target>
diff --git a/src/org/torproject/onionoo/Logger.java 
b/src/org/torproject/onionoo/Logger.java
index d84adf2..6906a6a 100644
--- a/src/org/torproject/onionoo/Logger.java
+++ b/src/org/torproject/onionoo/Logger.java
@@ -56,11 +56,25 @@ public class Logger {
   }
 
   public static void printStatusTime(String message) {
+    printStatusOrErrorTime(message, false);
+  }
+
+  public static void printErrorTime(String message) {
+    printStatusOrErrorTime(message, true);
+  }
+
+  private static void printStatusOrErrorTime(String message,
+      boolean printToSystemErr) {
     long now = currentTimeMillis();
     long millis = printedLastStatusMessage < 0 ? 0 :
         now - printedLastStatusMessage;
-    System.out.println("  " + message + " (" + Logger.formatMillis(millis)
-        + ").");
+    String line = "  " + message + " (" + Logger.formatMillis(millis)
+        + ").";
+    if (printToSystemErr) {
+      System.err.println(line);
+    } else {
+      System.out.println(line);
+    }
     printedLastStatusMessage = now;
   }
 }
diff --git a/src/org/torproject/onionoo/Main.java 
b/src/org/torproject/onionoo/Main.java
index 347701c..0ae12e4 100644
--- a/src/org/torproject/onionoo/Main.java
+++ b/src/org/torproject/onionoo/Main.java
@@ -18,7 +18,7 @@ public class Main {
     if (lf.acquireLock()) {
       Logger.printStatusTime("Acquired lock");
     } else {
-      Logger.printStatusTime("Could not acquire lock.  Is Onionoo "
+      Logger.printErrorTime("Could not acquire lock.  Is Onionoo "
           + "already running?  Terminating");
       return;
     }
@@ -107,7 +107,7 @@ public class Main {
     if (lf.releaseLock()) {
       Logger.printStatusTime("Released lock");
     } else {
-      Logger.printStatusTime("Could not release lock.  The next "
+      Logger.printErrorTime("Could not release lock.  The next "
           + "execution may not start as expected");
     }
 

_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to