mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Merge branch 'account-logging' into 'master'
Log contents of account directory for debugging See merge request briar/briar!1096
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.bramble.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -19,6 +20,7 @@ public class LogUtils {
|
||||
|
||||
/**
|
||||
* Logs the duration of a task.
|
||||
*
|
||||
* @param logger the logger to use
|
||||
* @param task a description of the task
|
||||
* @param start the start time of the task, as returned by {@link #now()}
|
||||
@@ -33,4 +35,26 @@ public class LogUtils {
|
||||
public static void logException(Logger logger, Level level, Throwable t) {
|
||||
if (logger.isLoggable(level)) logger.log(level, t.toString(), t);
|
||||
}
|
||||
|
||||
public static void logFileOrDir(Logger logger, Level level, File f) {
|
||||
if (logger.isLoggable(level)) {
|
||||
if (f.isFile()) {
|
||||
logWithType(logger, level, f, "F");
|
||||
} else if (f.isDirectory()) {
|
||||
logWithType(logger, level, f, "D");
|
||||
File[] children = f.listFiles();
|
||||
if (children != null) {
|
||||
for (File child : children)
|
||||
logFileOrDir(logger, level, child);
|
||||
}
|
||||
} else if (f.exists()) {
|
||||
logWithType(logger, level, f, "?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void logWithType(Logger logger, Level level, File f,
|
||||
String type) {
|
||||
logger.log(level, type + " " + f.getAbsolutePath() + " " + f.length());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user