mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-09-25 15:16:24 +00:00
Improve pretty printing of arrays, in particular the fetch-history array.
This commit is contained in:
@@ -748,8 +748,16 @@ public class ArchiveUtils {
|
||||
* @param obj Object to prettify
|
||||
* @return prettified String
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static String prettyString(Object obj) {
|
||||
return "<"+obj+">";
|
||||
// these things have to checked and casted unfortunately
|
||||
if (obj instanceof Object[]) {
|
||||
return prettyString((Object[]) obj);
|
||||
} else if (obj instanceof Map) {
|
||||
return prettyString((Map) obj);
|
||||
} else {
|
||||
return "<"+obj+">";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -777,29 +785,27 @@ public class ArchiveUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a slightly-improved String of Map[]
|
||||
* Provide a slightly-improved String of Object[]
|
||||
*
|
||||
* @param Map[]
|
||||
* @return prettified (in square brackets) of Map[]
|
||||
* @param Object[]
|
||||
* @return prettified (in square brackets) of Object[]
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static String prettyString(Map[] maps) {
|
||||
public static String prettyString(Object[] array) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("[ ");
|
||||
boolean needsComma = false;
|
||||
for( Map map : maps) {
|
||||
if(map==null) continue;
|
||||
for (Object o: array) {
|
||||
if(o==null) continue;
|
||||
if(needsComma) {
|
||||
builder.append(", ");
|
||||
}
|
||||
builder.append(prettyString(map));
|
||||
builder.append(prettyString(o));
|
||||
needsComma = true;
|
||||
}
|
||||
builder.append(" ]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
private static String loadVersion() {
|
||||
InputStream input = ArchiveUtils.class.getResourceAsStream(
|
||||
"/org/archive/util/version.txt");
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.apache.commons.lang.SerializationUtils;
|
||||
import org.archive.bdb.BdbModule;
|
||||
import org.archive.modules.CrawlURI;
|
||||
import org.archive.modules.Processor;
|
||||
import org.archive.util.ArchiveUtils;
|
||||
import org.archive.util.FileUtils;
|
||||
import org.archive.util.IoUtils;
|
||||
import org.archive.util.OneLineSimpleLogger;
|
||||
@@ -198,7 +199,7 @@ public abstract class PersistProcessor extends Processor {
|
||||
Map alist = (Map) SerializationUtils.deserialize(Base64.decodeBase64(splits[1].getBytes("UTF-8")));
|
||||
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.fine(splits[0] + " " + alist);
|
||||
logger.fine(splits[0] + " " + ArchiveUtils.prettyString(alist));
|
||||
}
|
||||
|
||||
if (historyMap != null) {
|
||||
@@ -211,7 +212,7 @@ public abstract class PersistProcessor extends Processor {
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Populates a new environment db from an old environment db or a persist
|
||||
* log. If path to new environment is not provided, only logs the entries
|
||||
|
||||
Reference in New Issue
Block a user