diff --git a/commons/src/main/java/org/archive/io/CrawlerJournal.java b/commons/src/main/java/org/archive/io/CrawlerJournal.java
index c2b9fa43..5f98a6a9 100644
--- a/commons/src/main/java/org/archive/io/CrawlerJournal.java
+++ b/commons/src/main/java/org/archive/io/CrawlerJournal.java
@@ -28,8 +28,11 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import java.util.zip.GZIPOutputStream;
+import org.apache.commons.lang.StringUtils;
import org.archive.checkpointing.Checkpoint;
import org.archive.util.ArchiveUtils;
import org.archive.util.FileUtils;
@@ -41,7 +44,9 @@ import org.archive.util.FileUtils;
* @author gojomo
*/
public class CrawlerJournal implements Closeable {
-
+ private static final Logger LOGGER = Logger.getLogger(
+ CrawlerJournal.class.getName());
+
/** prefix for error lines*/
public static final String LOG_ERROR = "E ";
/** prefix for timestamp lines */
@@ -103,49 +108,18 @@ public class CrawlerJournal implements Closeable {
*
* @param string String
*/
- public synchronized void writeLine(String string) {
+ public synchronized void writeLine(String... strs) {
try {
- this.out.write(string);
+ for(String s : strs) {
+ this.out.write(s);
+ }
this.out.write("\n");
noteLine();
} catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Write a line of two strings
- *
- * @param s1 String
- * @param s2 String
- */
- public synchronized void writeLine(String s1, String s2) {
- try {
- this.out.write(s1);
- this.out.write(s2);
- this.out.write("\n");
- noteLine();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Write a line of three strings
- *
- * @param s1 String
- * @param s2 String
- * @param s3 String
- */
- public synchronized void writeLine(String s1, String s2, String s3) {
- try {
- this.out.write(s1);
- this.out.write(s2);
- this.out.write(s3);
- this.out.write("\n");
- noteLine();
- } catch (IOException e) {
- e.printStackTrace();
+ LOGGER.log(
+ Level.SEVERE,
+ "problem writing journal line: "+StringUtils.join(strs),
+ e);
}
}
@@ -163,7 +137,7 @@ public class CrawlerJournal implements Closeable {
this.out.write("\n");
noteLine();
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.log(Level.SEVERE,"problem writing journal line: "+mstring, e);
}
}
@@ -202,7 +176,7 @@ public class CrawlerJournal implements Closeable {
this.out.close();
this.out = null;
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.log(Level.SEVERE,"problem closing journal", e);
}
}
diff --git a/commons/src/main/java/org/archive/util/ArchiveUtils.java b/commons/src/main/java/org/archive/util/ArchiveUtils.java
index e4ab9b55..414ca905 100644
--- a/commons/src/main/java/org/archive/util/ArchiveUtils.java
+++ b/commons/src/main/java/org/archive/util/ArchiveUtils.java
@@ -545,16 +545,6 @@ public class ArchiveUtils {
* @return Human readable string version of passed time
*/
public static String formatMillisecondsToConventional(long time) {
- return formatMillisecondsToConventional(time,true);
- }
-
- /**
- * Convert milliseconds value to a human-readable duration
- * @param time
- * @param toMs ignored
- * @return Human readable string version of passed time
- */
- public static String formatMillisecondsToConventional(long time, boolean toMs) {
return formatMillisecondsToConventional(time,5);
}
diff --git a/engine/src/main/java/org/archive/crawler/framework/CrawlJob.java b/engine/src/main/java/org/archive/crawler/framework/CrawlJob.java
index 1e95d974..015f0734 100644
--- a/engine/src/main/java/org/archive/crawler/framework/CrawlJob.java
+++ b/engine/src/main/java/org/archive/crawler/framework/CrawlJob.java
@@ -802,7 +802,7 @@ public class CrawlJob implements Comparable, ApplicationListener {
return "n/a";
}
long timeElapsed = stats.getCrawlElapsedTime();
- return ArchiveUtils.formatMillisecondsToConventional(timeElapsed,false);
+ return ArchiveUtils.formatMillisecondsToConventional(timeElapsed);
}
public Map threadReportData() {
diff --git a/engine/src/main/java/org/archive/crawler/frontier/FrontierJournal.java b/engine/src/main/java/org/archive/crawler/frontier/FrontierJournal.java
index bdfc35ab..9e0e6432 100644
--- a/engine/src/main/java/org/archive/crawler/frontier/FrontierJournal.java
+++ b/engine/src/main/java/org/archive/crawler/frontier/FrontierJournal.java
@@ -164,8 +164,7 @@ public class FrontierJournal extends CrawlerJournal {
// wait until at least ENOUGH_TO_START_CRAWLING URIs queued
recoveredEnough.await();
} catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LOGGER.log(Level.WARNING,"interrupted",e);
}
}
@@ -219,7 +218,7 @@ public class FrontierJournal extends CrawlerJournal {
newJournal.writeLine(read);
}
} catch (URIException e) {
- e.printStackTrace();
+ LOGGER.log(Level.WARNING,"bad hopsViaString: "+read.substring(3),e);
}
}
if((lines%PROGRESS_INTERVAL)==0) {
@@ -328,8 +327,7 @@ public class FrontierJournal extends CrawlerJournal {
br.close();
}
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ LOGGER.log(Level.WARNING,"problem importQueuesFromLog",e);
}
LOGGER.info("finished recovering frontier from "+source+" "
+qLines+" lines processed");