[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [onionoo/release] Use parameterized log statements.
commit b8e3e95f00e5a6e0a8a8fbd424a7d0c4b5e91860
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Tue Aug 21 10:22:01 2018 +0200
Use parameterized log statements.
---
.../java/org/torproject/onionoo/cron/Main.java | 8 +--
.../torproject/onionoo/docs/BandwidthStatus.java | 4 +-
.../torproject/onionoo/docs/ClientsHistory.java | 22 +++---
.../org/torproject/onionoo/docs/ClientsStatus.java | 4 +-
.../org/torproject/onionoo/docs/DocumentStore.java | 82 ++++++++++------------
.../org/torproject/onionoo/docs/NodeStatus.java | 30 ++++----
.../org/torproject/onionoo/docs/UpdateStatus.java | 4 +-
.../org/torproject/onionoo/docs/UptimeHistory.java | 17 +++--
.../org/torproject/onionoo/docs/UptimeStatus.java | 4 +-
.../org/torproject/onionoo/docs/WeightsStatus.java | 12 ++--
.../org/torproject/onionoo/server/NodeIndexer.java | 4 +-
.../onionoo/server/PerformanceMetrics.java | 45 +++++-------
.../org/torproject/onionoo/server/ServerMain.java | 4 +-
.../onionoo/updater/DescriptorQueue.java | 21 +++---
.../onionoo/updater/DescriptorSource.java | 6 +-
.../torproject/onionoo/updater/LookupService.java | 60 +++++++---------
.../onionoo/updater/StatusUpdateRunner.java | 17 +++--
.../onionoo/writer/DocumentWriterRunner.java | 5 +-
18 files changed, 158 insertions(+), 191 deletions(-)
diff --git a/src/main/java/org/torproject/onionoo/cron/Main.java b/src/main/java/org/torproject/onionoo/cron/Main.java
index 9b34356..8e5812d 100644
--- a/src/main/java/org/torproject/onionoo/cron/Main.java
+++ b/src/main/java/org/torproject/onionoo/cron/Main.java
@@ -115,8 +115,8 @@ public class Main implements Runnable {
int initialDelay = (75 - currentMinute + currentMinute % 5) % 60;
/* Run after initialDelay delay and then every hour. */
- this.log.info("Periodic updater will start every hour at minute "
- + ((currentMinute + initialDelay) % 60) + ".");
+ this.log.info("Periodic updater will start every hour at minute {}.",
+ (currentMinute + initialDelay) % 60);
this.scheduler.scheduleAtFixedRate(mainRunnable, initialDelay, 60,
TimeUnit.MINUTES);
}
@@ -210,10 +210,10 @@ public class Main implements Runnable {
this.dwr.logStatistics();
}
if (this.dso != null) {
- this.log.info("Descriptor source\n" + this.dso.getStatsString());
+ this.log.info("Descriptor source\n{}", this.dso.getStatsString());
}
if (this.ds != null) {
- this.log.info("Document store\n" + this.ds.getStatsString());
+ this.log.info("Document store\n{}", this.ds.getStatsString());
}
}
diff --git a/src/main/java/org/torproject/onionoo/docs/BandwidthStatus.java b/src/main/java/org/torproject/onionoo/docs/BandwidthStatus.java
index 20e2e27..258e0e4 100644
--- a/src/main/java/org/torproject/onionoo/docs/BandwidthStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/BandwidthStatus.java
@@ -55,8 +55,8 @@ public class BandwidthStatus extends Document {
String line = s.nextLine();
String[] parts = line.split(" ");
if (parts.length != 6) {
- log.error("Illegal line '" + line + "' in bandwidth "
- + "history. Skipping this line.");
+ log.error("Illegal line '{}' in bandwidth history. Skipping this "
+ + "line.", line);
continue;
}
SortedMap<Long, long[]> history = parts[0].equals("r")
diff --git a/src/main/java/org/torproject/onionoo/docs/ClientsHistory.java b/src/main/java/org/torproject/onionoo/docs/ClientsHistory.java
index e4800e3..0efe181 100644
--- a/src/main/java/org/torproject/onionoo/docs/ClientsHistory.java
+++ b/src/main/java/org/torproject/onionoo/docs/ClientsHistory.java
@@ -73,29 +73,28 @@ public class ClientsHistory implements Comparable<ClientsHistory> {
String responseHistoryString) {
String[] parts = responseHistoryString.split(" ", 8);
if (parts.length != 8) {
- log.warn("Invalid number of space-separated strings in clients "
- + "history: '" + responseHistoryString + "'. Skipping");
+ log.warn("Invalid number of space-separated strings in clients history: "
+ + "'{}'. Skipping", responseHistoryString);
return null;
}
long startMillis = DateTimeHelper.parse(parts[0] + " " + parts[1]);
long endMillis = DateTimeHelper.parse(parts[2] + " " + parts[3]);
if (startMillis < 0L || endMillis < 0L) {
- log.warn("Invalid start or end timestamp in clients history: '"
- + responseHistoryString + "'. Skipping.");
+ log.warn("Invalid start or end timestamp in clients history: '{}'. "
+ + "Skipping.", responseHistoryString);
return null;
}
if (startMillis >= endMillis) {
- log.warn("Start timestamp must be smaller than end timestamp in "
- + "clients history: '" + responseHistoryString
- + "'. Skipping.");
+ log.warn("Start timestamp must be smaller than end timestamp in clients "
+ + "history: '{}'. Skipping.", responseHistoryString);
return null;
}
double totalResponses;
try {
totalResponses = Double.parseDouble(parts[4]);
} catch (NumberFormatException e) {
- log.warn("Invalid response number format in clients history: '"
- + responseHistoryString + "'. Skipping.");
+ log.warn("Invalid response number format in clients history: '{}'. "
+ + "Skipping.", responseHistoryString);
return null;
}
SortedMap<String, Double> responsesByCountry =
@@ -106,9 +105,8 @@ public class ClientsHistory implements Comparable<ClientsHistory> {
parseResponses(parts[7]);
if (responsesByCountry == null || responsesByTransport == null
|| responsesByVersion == null) {
- log.warn("Invalid format of responses by country, transport, or "
- + "version in clients history: '" + responseHistoryString
- + "'. Skipping.");
+ log.warn("Invalid format of responses by country, transport, or version "
+ + "in clients history: '{}'. Skipping.", responseHistoryString);
return null;
}
return new ClientsHistory(startMillis, endMillis, totalResponses,
diff --git a/src/main/java/org/torproject/onionoo/docs/ClientsStatus.java b/src/main/java/org/torproject/onionoo/docs/ClientsStatus.java
index 21a76e1..6de115b 100644
--- a/src/main/java/org/torproject/onionoo/docs/ClientsStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/ClientsStatus.java
@@ -44,8 +44,8 @@ public class ClientsStatus extends Document {
if (parsedLine != null) {
this.history.add(parsedLine);
} else {
- log.error("Could not parse clients history line '"
- + line + "'. Skipping.");
+ log.error("Could not parse clients history line '{}'. Skipping.",
+ line);
}
}
}
diff --git a/src/main/java/org/torproject/onionoo/docs/DocumentStore.java b/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
index c5444c5..49176f8 100644
--- a/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
+++ b/src/main/java/org/torproject/onionoo/docs/DocumentStore.java
@@ -135,8 +135,8 @@ public class DocumentStore {
this.listedFiles += parsedNodeStatuses.size();
this.listOperations++;
} catch (IOException e) {
- log.error("Could not read file '"
- + summaryFile.getAbsolutePath() + "'.", e);
+ log.error("Could not read file '{}'.", summaryFile.getAbsolutePath(),
+ e);
}
}
}
@@ -339,15 +339,15 @@ public class DocumentStore {
|| document instanceof UpdateStatus) {
documentString = document.toDocumentString();
} else {
- log.error("Serializing is not supported for type "
- + document.getClass().getName() + ".");
+ log.error("Serializing is not supported for type {}.",
+ document.getClass().getName());
return false;
}
try {
if (documentString.length() > ONE_MIBIBYTE) {
- log.warn("Attempting to store very large document file: path='"
- + documentFile.getAbsolutePath() + "', bytes="
- + documentString.length());
+ log.warn("Attempting to store very large document file: path='{}', "
+ + "bytes={}", documentFile.getAbsolutePath(),
+ documentString.length());
}
documentFile.getParentFile().mkdirs();
File documentTempFile = new File(
@@ -358,8 +358,8 @@ public class DocumentStore {
this.storedFiles++;
this.storedBytes += documentString.length();
} catch (IOException e) {
- log.error("Could not write file '"
- + documentFile.getAbsolutePath() + "'.", e);
+ log.error("Could not write file '{}'.", documentFile.getAbsolutePath(),
+ e);
return false;
}
return true;
@@ -419,10 +419,10 @@ public class DocumentStore {
String contact = null;
for (String orAddressAndPort : detailsDocument.getOrAddresses()) {
if (!orAddressAndPort.contains(":")) {
- log.warn("Attempt to create summary document from details "
- + "document for fingerprint " + fingerprint + " failed "
- + "because of invalid OR address/port: '" + orAddressAndPort
- + "'. Not returning a summary document in this case.");
+ log.warn("Attempt to create summary document from details document for "
+ + "fingerprint {} failed because of invalid OR address/port: '{}'. "
+ + "Not returning a summary document in this case.", fingerprint,
+ orAddressAndPort);
return null;
}
String orAddress = orAddressAndPort.substring(0,
@@ -464,9 +464,8 @@ public class DocumentStore {
/* Document file does not exist. That's okay. */
return null;
} else if (documentFile.isDirectory()) {
- log.error("Could not read file '"
- + documentFile.getAbsolutePath() + "', because it is a "
- + "directory.");
+ log.error("Could not read file '{}', because it is a directory.",
+ documentFile.getAbsolutePath());
return null;
}
String documentString;
@@ -487,14 +486,12 @@ public class DocumentStore {
this.retrievedFiles++;
this.retrievedBytes += documentString.length();
} catch (IOException e) {
- log.error("Could not read file '"
- + documentFile.getAbsolutePath() + "'.", e);
+ log.error("Could not read file '{}'.", documentFile.getAbsolutePath(), e);
return null;
}
if (documentString.length() > ONE_MIBIBYTE) {
- log.warn("Retrieved very large document file: path='"
- + documentFile.getAbsolutePath() + "', bytes="
- + documentString.length());
+ log.warn("Retrieved very large document file: path='{}', bytes={}",
+ documentFile.getAbsolutePath(), documentString.length());
}
T result = null;
if (!parse) {
@@ -517,8 +514,8 @@ public class DocumentStore {
return this.retrieveParsedDocumentFile(documentType, "{"
+ documentString + "}");
} else {
- log.error("Parsing is not supported for type "
- + documentType.getName() + ".");
+ log.error("Parsing is not supported for type {}.",
+ documentType.getName());
}
return result;
}
@@ -534,8 +531,8 @@ public class DocumentStore {
log.error(e.getMessage(), e);
}
if (result == null) {
- log.error("Could not initialize parsed status file of "
- + "type " + documentType.getName() + ".");
+ log.error("Could not initialize parsed status file of type {}.",
+ documentType.getName());
}
return result;
}
@@ -551,8 +548,8 @@ public class DocumentStore {
log.error(e.getMessage(), e);
}
if (result == null) {
- log.error("Could not initialize parsed document of type "
- + documentType.getName() + ".");
+ log.error("Could not initialize parsed document of type {}.",
+ documentType.getName());
}
return result;
}
@@ -568,8 +565,8 @@ public class DocumentStore {
log.error(e.getMessage(), e);
}
if (result == null) {
- log.error("Could not initialize unparsed document of type "
- + documentType.getName() + ".");
+ log.error("Could not initialize unparsed document of type {}.",
+ documentType.getName());
}
return result;
}
@@ -611,8 +608,7 @@ public class DocumentStore {
Class<T> documentType, String fingerprint) {
File documentFile = this.getDocumentFile(documentType, fingerprint);
if (documentFile == null || !documentFile.delete()) {
- log.error("Could not delete file '"
- + documentFile.getAbsolutePath() + "'.");
+ log.error("Could not delete file '{}'.", documentFile.getAbsolutePath());
return false;
}
this.removedFiles++;
@@ -624,9 +620,9 @@ public class DocumentStore {
File documentFile = null;
if (fingerprint == null && !documentType.equals(UpdateStatus.class)
&& !documentType.equals(UptimeStatus.class)) {
- log.warn("Attempted to locate a document file of type "
- + documentType.getName() + " without providing a fingerprint. "
- + "Such a file does not exist.");
+ log.warn("Attempted to locate a document file of type {} without "
+ + "providing a fingerprint. Such a file does not exist.",
+ documentType.getName());
return null;
}
File directory = null;
@@ -739,8 +735,8 @@ public class DocumentStore {
if (line != null) {
sb.append(line).append("\n");
} else {
- log.error("Could not serialize relay node status '"
- + relay.getFingerprint() + "'");
+ log.error("Could not serialize relay node status '{}'",
+ relay.getFingerprint());
}
}
for (NodeStatus bridge : cachedBridges.values()) {
@@ -748,8 +744,8 @@ public class DocumentStore {
if (line != null) {
sb.append(line).append("\n");
} else {
- log.error("Could not serialize bridge node status '"
- + bridge.getFingerprint() + "'");
+ log.error("Could not serialize bridge node status '{}'",
+ bridge.getFingerprint());
}
}
String documentString = sb.toString();
@@ -761,8 +757,7 @@ public class DocumentStore {
this.storedFiles++;
this.storedBytes += documentString.length();
} catch (IOException e) {
- log.error("Could not write file '"
- + summaryFile.getAbsolutePath() + "'.", e);
+ log.error("Could not write file '{}'.", summaryFile.getAbsolutePath(), e);
}
}
@@ -791,8 +786,8 @@ public class DocumentStore {
if (line != null) {
sb.append(line).append("\n");
} else {
- log.error("Could not serialize relay summary document '"
- + summaryDocument.getFingerprint() + "'");
+ log.error("Could not serialize relay summary document '{}'",
+ summaryDocument.getFingerprint());
}
}
String documentString = sb.toString();
@@ -805,8 +800,7 @@ public class DocumentStore {
this.storedFiles++;
this.storedBytes += documentString.length();
} catch (IOException e) {
- log.error("Could not write file '"
- + summaryFile.getAbsolutePath() + "'.", e);
+ log.error("Could not write file '{}'.", summaryFile.getAbsolutePath(), e);
}
}
diff --git a/src/main/java/org/torproject/onionoo/docs/NodeStatus.java b/src/main/java/org/torproject/onionoo/docs/NodeStatus.java
index 1940198..9080b84 100644
--- a/src/main/java/org/torproject/onionoo/docs/NodeStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/NodeStatus.java
@@ -553,8 +553,8 @@ public class NodeStatus extends Document {
try {
String[] parts = documentString.trim().split("\t");
if (parts.length < 23) {
- log.error("Too few space-separated values in line '"
- + documentString.trim() + "'. Skipping.");
+ log.error("Too few space-separated values in line '{}'. Skipping.",
+ documentString.trim());
return null;
}
String fingerprint = parts[2];
@@ -568,8 +568,8 @@ public class NodeStatus extends Document {
if (addresses.contains(";")) {
String[] addressParts = addresses.split(";", -1);
if (addressParts.length != 3) {
- log.error("Invalid addresses entry in line '"
- + documentString.trim() + "'. Skipping.");
+ log.error("Invalid addresses entry in line '{}'. Skipping.",
+ documentString.trim());
return null;
}
address = addressParts[0];
@@ -590,8 +590,8 @@ public class NodeStatus extends Document {
long lastSeenMillis = DateTimeHelper.parse(parts[4] + " "
+ parts[5]);
if (lastSeenMillis < 0L) {
- log.error("Parse exception while parsing node status "
- + "line '" + documentString + "'. Skipping.");
+ log.error("Parse exception while parsing node status line '{}'. "
+ + "Skipping.", documentString);
return null;
} else if (lastSeenMillis == 0L) {
log.debug("Skipping node status with fingerprint {} that has so far "
@@ -617,8 +617,8 @@ public class NodeStatus extends Document {
}
long firstSeenMillis = DateTimeHelper.parse(parts[15] + " " + parts[16]);
if (firstSeenMillis < 0L) {
- log.error("Parse exception while parsing node status "
- + "line '" + documentString + "'. Skipping.");
+ log.error("Parse exception while parsing node status line '{}'. "
+ + "Skipping.", documentString);
return null;
}
nodeStatus.setFirstSeenMillis(firstSeenMillis);
@@ -627,8 +627,8 @@ public class NodeStatus extends Document {
lastChangedAddresses = DateTimeHelper.parse(parts[17] + " "
+ parts[18]);
if (lastChangedAddresses < 0L) {
- log.error("Parse exception while parsing node status "
- + "line '" + documentString + "'. Skipping.");
+ log.error("Parse exception while parsing node status line '{}'. "
+ + "Skipping.", documentString);
return null;
}
}
@@ -693,16 +693,14 @@ public class NodeStatus extends Document {
}
return nodeStatus;
} catch (NumberFormatException e) {
- log.error("Number format exception while parsing node "
- + "status line '" + documentString + "': " + e.getMessage()
- + ". Skipping.");
+ log.error("Number format exception while parsing node status line '{}'. "
+ + "Skipping.", documentString, e);
return null;
} catch (Exception e) {
/* This catch block is only here to handle yet unknown errors. It
* should go away once we're sure what kind of errors can occur. */
- log.error("Unknown exception while parsing node status "
- + "line '" + documentString + "': " + e.getMessage() + ". "
- + "Skipping.");
+ log.error("Unknown exception while parsing node status line '{}'. "
+ + "Skipping.", documentString, e);
return null;
}
}
diff --git a/src/main/java/org/torproject/onionoo/docs/UpdateStatus.java b/src/main/java/org/torproject/onionoo/docs/UpdateStatus.java
index 889a52d..11f32f9 100644
--- a/src/main/java/org/torproject/onionoo/docs/UpdateStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/UpdateStatus.java
@@ -25,8 +25,8 @@ public class UpdateStatus extends Document {
try {
this.updatedMillis = Long.parseLong(documentString.trim());
} catch (NumberFormatException e) {
- log.error("Could not parse timestamp '" + documentString + "'. "
- + "Setting to 1970-01-01 00:00:00.");
+ log.error("Could not parse timestamp '{}'. Setting to 1970-01-01 "
+ + "00:00:00.", documentString);
this.updatedMillis = 0L;
}
}
diff --git a/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java b/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java
index 0297b37..8bbb5b7 100644
--- a/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java
+++ b/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java
@@ -58,32 +58,31 @@ public class UptimeHistory implements Comparable<UptimeHistory> {
public static UptimeHistory fromString(String uptimeHistoryString) {
String[] parts = uptimeHistoryString.split(" ", -1);
if (parts.length < 3) {
- log.warn("Invalid number of space-separated strings in uptime "
- + "history: '" + uptimeHistoryString + "'. Skipping");
+ log.warn("Invalid number of space-separated strings in uptime history: "
+ + "'{}'. Skipping", uptimeHistoryString);
return null;
}
boolean relay = false;
if (parts[0].equalsIgnoreCase("r")) {
relay = true;
} else if (!parts[0].equals("b")) {
- log.warn("Invalid node type in uptime history: '"
- + uptimeHistoryString + "'. Supported types are 'r', 'R', and "
- + "'b'. Skipping.");
+ log.warn("Invalid node type in uptime history: '{}'. Supported types are "
+ + "'r', 'R', and 'b'. Skipping.", uptimeHistoryString);
return null;
}
long startMillis = DateTimeHelper.parse(parts[1],
DateTimeHelper.DATEHOUR_NOSPACE_FORMAT);
if (DateTimeHelper.NO_TIME_AVAILABLE == startMillis) {
- log.warn("Invalid start timestamp in uptime history: '"
- + uptimeHistoryString + "'. Skipping.");
+ log.warn("Invalid start timestamp in uptime history: '{}'. Skipping.",
+ uptimeHistoryString);
return null;
}
int uptimeHours;
try {
uptimeHours = Integer.parseInt(parts[2]);
} catch (NumberFormatException e) {
- log.warn("Invalid number format in uptime history: '"
- + uptimeHistoryString + "'. Skipping.");
+ log.warn("Invalid number format in uptime history: '{}'. Skipping.",
+ uptimeHistoryString);
return null;
}
SortedSet<String> flags = null;
diff --git a/src/main/java/org/torproject/onionoo/docs/UptimeStatus.java b/src/main/java/org/torproject/onionoo/docs/UptimeStatus.java
index bec5028..8fa5960 100644
--- a/src/main/java/org/torproject/onionoo/docs/UptimeStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/UptimeStatus.java
@@ -51,8 +51,8 @@ public class UptimeStatus extends Document {
this.bridgeHistory.add(parsedLine);
}
} else {
- log.error("Could not parse uptime history line '"
- + line + "'. Skipping.");
+ log.error("Could not parse uptime history line '{}'. Skipping.",
+ line);
}
}
}
diff --git a/src/main/java/org/torproject/onionoo/docs/WeightsStatus.java b/src/main/java/org/torproject/onionoo/docs/WeightsStatus.java
index f3b5452..c8b6fde 100644
--- a/src/main/java/org/torproject/onionoo/docs/WeightsStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/WeightsStatus.java
@@ -58,8 +58,8 @@ public class WeightsStatus extends Document {
continue;
}
if (parts.length != 9 && parts.length != 11) {
- log.error("Illegal line '" + line + "' in weights "
- + "status file. Skipping this line.");
+ log.error("Illegal line '{}' in weights status file. Skipping this "
+ + "line.", line);
continue;
}
if (parts[4].equals("NaN")) {
@@ -75,8 +75,8 @@ public class WeightsStatus extends Document {
break;
}
if (validAfterMillis > freshUntilMillis) {
- log.error("Illegal dates in '" + line + "' of weights "
- + "status file. Skipping.");
+ log.error("Illegal dates in '{}' of weights status file. Skipping.",
+ line);
break;
}
long[] interval = new long[] { validAfterMillis, freshUntilMillis };
@@ -91,8 +91,8 @@ public class WeightsStatus extends Document {
weights[6] = parseWeightDouble(parts[10]);
}
} catch (NumberFormatException e) {
- log.error("Could not parse weights values in line '" + line
- + "' while reading weights status file. Skipping.");
+ log.error("Could not parse weights values in line '{}' while reading "
+ + "weights status file. Skipping.", line);
break;
}
this.history.put(interval, weights);
diff --git a/src/main/java/org/torproject/onionoo/server/NodeIndexer.java b/src/main/java/org/torproject/onionoo/server/NodeIndexer.java
index 73b6777..8388f33 100644
--- a/src/main/java/org/torproject/onionoo/server/NodeIndexer.java
+++ b/src/main/java/org/torproject/onionoo/server/NodeIndexer.java
@@ -37,8 +37,8 @@ public class NodeIndexer implements ServletContextListener, Runnable {
File outDir = new File(System.getProperty("onionoo.basedir",
"/srv/onionoo.torproject.org/onionoo"), "out");
if (!outDir.exists() || !outDir.isDirectory()) {
- log.error("\n\n\tOut-dir not found! Expected directory: " + outDir
- + "\n\tSet system property 'onionoo.basedir'.");
+ log.error("\n\n\tOut-dir not found! Expected directory: {}"
+ + "\n\tSet system property 'onionoo.basedir'.", outDir);
System.exit(1);
}
DocumentStore documentStore = DocumentStoreFactory.getDocumentStore();
diff --git a/src/main/java/org/torproject/onionoo/server/PerformanceMetrics.java b/src/main/java/org/torproject/onionoo/server/PerformanceMetrics.java
index 98401ae..d0e7002 100644
--- a/src/main/java/org/torproject/onionoo/server/PerformanceMetrics.java
+++ b/src/main/java/org/torproject/onionoo/server/PerformanceMetrics.java
@@ -65,26 +65,19 @@ public class PerformanceMetrics {
SimpleDateFormat dateTimeFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
dateTimeFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- log.info("Request statistics ("
- + dateTimeFormat.format(lastLoggedMillis
- + LOG_INTERVAL_MILLIS) + ", " + (LOG_INTERVAL_SECONDS)
- + " s):");
- log.info(" Total processed requests: "
- + totalProcessedRequests);
- log.info(" Most frequently requested resource: "
- + requestsByResourceType);
- log.info(" Most frequently requested parameter "
- + "combinations: " + requestsByParameters);
- log.info(" Matching relays per request: "
- + matchingRelayDocuments);
- log.info(" Matching bridges per request: "
- + matchingBridgeDocuments);
- log.info(" Written characters per response: "
- + writtenChars);
- log.info(" Milliseconds to handle request: "
- + handleRequestMillis);
- log.info(" Milliseconds to build response: "
- + buildResponseMillis);
+ log.info("Request statistics ({}, {} s):",
+ dateTimeFormat.format(lastLoggedMillis + LOG_INTERVAL_MILLIS),
+ LOG_INTERVAL_SECONDS);
+ log.info(" Total processed requests: {}", totalProcessedRequests);
+ log.info(" Most frequently requested resource: {}",
+ requestsByResourceType);
+ log.info(" Most frequently requested parameter combinations: {}",
+ requestsByParameters);
+ log.info(" Matching relays per request: {}", matchingRelayDocuments);
+ log.info(" Matching bridges per request: {}", matchingBridgeDocuments);
+ log.info(" Written characters per response: {}", writtenChars);
+ log.info(" Milliseconds to handle request: {}", handleRequestMillis);
+ log.info(" Milliseconds to build response: {}", buildResponseMillis);
totalProcessedRequests.clear();
requestsByResourceType.clear();
requestsByParameters.clear();
@@ -101,9 +94,9 @@ public class PerformanceMetrics {
totalProcessedRequests.increment();
long handlingTime = parsedRequestMillis - receivedRequestMillis;
if (handlingTime > DateTimeHelper.ONE_SECOND) {
- log.warn("longer request handling: " + handlingTime + " ms for "
- + resourceType + " params: " + parameterKeys + " and "
- + charsWritten + " chars.");
+ log.warn("longer request handling: {} ms for {} params: {} and {} "
+ + "chars.", handlingTime, resourceType, parameterKeys,
+ charsWritten);
}
handleRequestMillis.addLong(handlingTime);
requestsByResourceType.addString(resourceType);
@@ -113,9 +106,9 @@ public class PerformanceMetrics {
writtenChars.addLong(charsWritten);
long responseTime = writtenResponseMillis - parsedRequestMillis;
if (responseTime > DateTimeHelper.ONE_SECOND) {
- log.warn("longer response building: " + responseTime + " ms for "
- + resourceType + " params: " + parameterKeys + " and "
- + charsWritten + " chars.");
+ log.warn("longer response building: {} ms for {} params: {} and {} "
+ + "chars.", responseTime, resourceType, parameterKeys,
+ charsWritten);
}
buildResponseMillis.addLong(responseTime);
}
diff --git a/src/main/java/org/torproject/onionoo/server/ServerMain.java b/src/main/java/org/torproject/onionoo/server/ServerMain.java
index a60974b..03a4f18 100644
--- a/src/main/java/org/torproject/onionoo/server/ServerMain.java
+++ b/src/main/java/org/torproject/onionoo/server/ServerMain.java
@@ -18,14 +18,14 @@ public class ServerMain {
public static void main(String[] args) {
try {
Resource onionooXml = Resource.newSystemResource("jetty.xml");
- log.info("Reading configuration from '" + onionooXml + "'.");
+ log.info("Reading configuration from '{}'.", onionooXml);
XmlConfiguration configuration = new XmlConfiguration(
onionooXml.getInputStream());
Server server = (Server) configuration.configure();
server.start();
server.join();
} catch (Exception ex) {
- log.error("Exiting, because of: " + ex.getMessage(), ex);
+ log.error("Exiting, because of: {}", ex.getMessage(), ex);
System.exit(1);
}
}
diff --git a/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java b/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java
index d00b8b2..76e46a2 100644
--- a/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java
+++ b/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java
@@ -89,14 +89,14 @@ class DescriptorQueue {
String[] parts = line.split(" ", 2);
excludedFiles.put(parts[1], Long.parseLong(parts[0]));
} catch (NumberFormatException e) {
- log.error("Illegal line '" + line + "' in parse "
- + "history. Skipping line.");
+ log.error("Illegal line '{}' in parse history. Skipping line.",
+ line);
}
}
} catch (IOException e) {
- log.error("Could not read history file '"
- + this.historyFile.getAbsolutePath() + "'. Not excluding "
- + "descriptors in this execution.", e);
+ log.error("Could not read history file '{}'. Not excluding "
+ + "descriptors in this execution.",
+ this.historyFile.getAbsolutePath(), e);
return;
}
this.historySizeBefore = excludedFiles.size();
@@ -128,9 +128,8 @@ class DescriptorQueue {
+ "\n");
}
} catch (IOException e) {
- log.error("Could not write history file '"
- + this.historyFile.getAbsolutePath() + "'. Not excluding "
- + "descriptors in next execution.");
+ log.error("Could not write history file '{}'. Not excluding descriptors "
+ + "in next execution.", this.historyFile.getAbsolutePath());
}
}
@@ -144,9 +143,9 @@ class DescriptorQueue {
this.descriptors = this.descriptorReader.readDescriptors(
this.directory).iterator();
} else {
- log.error("Directory " + this.directory.getAbsolutePath()
- + " either does not exist or is not a directory. Not adding "
- + "to descriptor reader.");
+ log.error("Directory {} either does not exist or is not a directory. "
+ + "Not adding to descriptor reader.",
+ this.directory.getAbsolutePath());
return null;
}
}
diff --git a/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java b/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java
index 64bb0e4..65d342a 100644
--- a/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java
+++ b/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java
@@ -201,9 +201,9 @@ public class DescriptorSource {
}
}
if (descriptorType == null) {
- log.warn("Unrecognized descriptor in "
- + this.inArchiveDir.getAbsolutePath() + " with annotations "
- + descriptor.getAnnotations() + ". Skipping descriptor.");
+ log.warn("Unrecognized descriptor in {} with annotations {}. Skipping "
+ + "descriptor.", this.inArchiveDir.getAbsolutePath(),
+ descriptor.getAnnotations());
continue;
}
for (DescriptorListener descriptorListener :
diff --git a/src/main/java/org/torproject/onionoo/updater/LookupService.java b/src/main/java/org/torproject/onionoo/updater/LookupService.java
index dd35b59..495fec7 100644
--- a/src/main/java/org/torproject/onionoo/updater/LookupService.java
+++ b/src/main/java/org/torproject/onionoo/updater/LookupService.java
@@ -133,9 +133,8 @@ public class LookupService {
while ((line = br.readLine()) != null) {
String[] parts = line.split(",", -1);
if (parts.length < 9) {
- log.error("Illegal line '" + line + "' in "
- + this.geoLite2CityBlocksIPv4CsvFile.getAbsolutePath()
- + ".");
+ log.error("Illegal line '{}' in {}.", line,
+ this.geoLite2CityBlocksIPv4CsvFile.getAbsolutePath());
return lookupResults;
}
try {
@@ -143,18 +142,15 @@ public class LookupService {
String startAddressString = networkAddressAndMask[0];
long startIpNum = this.parseAddressString(startAddressString);
if (startIpNum < 0L) {
- log.error("Illegal IP address in '" + line + "' in "
- + this.geoLite2CityBlocksIPv4CsvFile.getAbsolutePath()
- + ".");
+ log.error("Illegal IP address in '{}' in {}.", line,
+ this.geoLite2CityBlocksIPv4CsvFile.getAbsolutePath());
return lookupResults;
}
int networkMaskLength = networkAddressAndMask.length < 2 ? 0
: Integer.parseInt(networkAddressAndMask[1]);
if (networkMaskLength < 8 || networkMaskLength > 32) {
- log.error("Missing or illegal network mask in '" + line
- + "' in "
- + this.geoLite2CityBlocksIPv4CsvFile.getAbsolutePath()
- + ".");
+ log.error("Missing or illegal network mask in '{}' in {}.", line,
+ this.geoLite2CityBlocksIPv4CsvFile.getAbsolutePath());
return lookupResults;
}
if (parts[1].length() == 0 && parts[2].length() == 0) {
@@ -175,17 +171,14 @@ public class LookupService {
}
}
} catch (NumberFormatException e) {
- log.error("Number format exception while parsing line '" + line
- + "' in "
- + this.geoLite2CityBlocksIPv4CsvFile.getAbsolutePath()
- + ".", e);
+ log.error("Number format exception while parsing line '{}' in {}.",
+ line, this.geoLite2CityBlocksIPv4CsvFile.getAbsolutePath(), e);
return lookupResults;
}
}
} catch (IOException e) {
- log.error("I/O exception while reading "
- + this.geoLite2CityBlocksIPv4CsvFile.getAbsolutePath()
- + ": " + e);
+ log.error("I/O exception while reading {}: {}",
+ this.geoLite2CityBlocksIPv4CsvFile.getAbsolutePath(), e);
return lookupResults;
}
@@ -198,9 +191,8 @@ public class LookupService {
while ((line = br.readLine()) != null) {
String[] parts = line.replaceAll("\"", "").split(",", 13);
if (parts.length != 13) {
- log.error("Illegal line '" + line + "' in "
- + this.geoLite2CityLocationsEnCsvFile.getAbsolutePath()
- + ".");
+ log.error("Illegal line '{}' in {}.", line,
+ this.geoLite2CityLocationsEnCsvFile.getAbsolutePath());
return lookupResults;
}
@@ -210,17 +202,14 @@ public class LookupService {
blockLocations.put(locId, line);
}
} catch (NumberFormatException e) {
- log.error("Number format exception while parsing line "
- + "'" + line + "' in "
- + this.geoLite2CityLocationsEnCsvFile.getAbsolutePath()
- + ".");
+ log.error("Number format exception while parsing line '{}' in {}.",
+ line, this.geoLite2CityLocationsEnCsvFile.getAbsolutePath());
return lookupResults;
}
}
} catch (IOException e) {
- log.error("I/O exception while reading "
- + this.geoLite2CityLocationsEnCsvFile.getAbsolutePath()
- + ": " + e);
+ log.error("I/O exception while reading {}: {}",
+ this.geoLite2CityLocationsEnCsvFile.getAbsolutePath(), e);
return lookupResults;
}
@@ -236,15 +225,15 @@ public class LookupService {
while ((line = br.readLine()) != null) {
String[] parts = line.replaceAll("\"", "").split(",", 3);
if (parts.length != 3) {
- log.error("Illegal line '" + line + "' in "
- + geoIpAsNum2CsvFile.getAbsolutePath() + ".");
+ log.error("Illegal line '{}' in {}.", line,
+ geoIpAsNum2CsvFile.getAbsolutePath());
return lookupResults;
}
try {
long startIpNum = Long.parseLong(parts[0]);
if (startIpNum <= previousStartIpNum) {
- log.error("Line '" + line + "' not sorted in "
- + geoIpAsNum2CsvFile.getAbsolutePath() + ".");
+ log.error("Line '{}' not sorted in {}.", line,
+ geoIpAsNum2CsvFile.getAbsolutePath());
return lookupResults;
}
previousStartIpNum = startIpNum;
@@ -274,15 +263,14 @@ public class LookupService {
break;
}
} catch (NumberFormatException e) {
- log.error("Number format exception while parsing line "
- + "'" + line + "' in "
- + geoIpAsNum2CsvFile.getAbsolutePath() + ".");
+ log.error("Number format exception while parsing line '{}' in {}.",
+ line, geoIpAsNum2CsvFile.getAbsolutePath());
return lookupResults;
}
}
} catch (IOException e) {
- log.error("I/O exception while reading "
- + geoIpAsNum2CsvFile.getAbsolutePath() + ": " + e);
+ log.error("I/O exception while reading {}: {}",
+ geoIpAsNum2CsvFile.getAbsolutePath(), e);
return lookupResults;
}
diff --git a/src/main/java/org/torproject/onionoo/updater/StatusUpdateRunner.java b/src/main/java/org/torproject/onionoo/updater/StatusUpdateRunner.java
index 19d5c4b..d7eddfe 100644
--- a/src/main/java/org/torproject/onionoo/updater/StatusUpdateRunner.java
+++ b/src/main/java/org/torproject/onionoo/updater/StatusUpdateRunner.java
@@ -37,10 +37,9 @@ public class StatusUpdateRunner {
/** Lets each configured status updater update its status files. */
public void updateStatuses() {
for (StatusUpdater su : this.statusUpdaters) {
- log.debug("Begin update of " + su.getClass().getSimpleName());
+ log.debug("Begin update of {}", su.getClass().getSimpleName());
su.updateStatuses();
- log.info(su.getClass().getSimpleName()
- + " updated status files");
+ log.info("{} updated status files", su.getClass().getSimpleName());
}
}
@@ -49,14 +48,14 @@ public class StatusUpdateRunner {
for (StatusUpdater su : this.statusUpdaters) {
String statsString = su.getStatsString();
if (statsString != null) {
- LoggerFactory.getLogger("statistics").info(
- su.getClass().getSimpleName() + "\n" + statsString);
+ LoggerFactory.getLogger("statistics").info("{}\n{}",
+ su.getClass().getSimpleName(), statsString);
}
}
- LoggerFactory.getLogger("statistics").info("GeoIP lookup service\n"
- + this.ls.getStatsString());
- LoggerFactory.getLogger("statistics").info("Reverse domain name "
- + "resolver\n" + this.rdnr.getStatsString());
+ LoggerFactory.getLogger("statistics")
+ .info("GeoIP lookup service\n{}", this.ls.getStatsString());
+ LoggerFactory.getLogger("statistics")
+ .info("Reverse domain name resolver\n{}", this.rdnr.getStatsString());
}
}
diff --git a/src/main/java/org/torproject/onionoo/writer/DocumentWriterRunner.java b/src/main/java/org/torproject/onionoo/writer/DocumentWriterRunner.java
index 4ab8f7e..d69c129 100644
--- a/src/main/java/org/torproject/onionoo/writer/DocumentWriterRunner.java
+++ b/src/main/java/org/torproject/onionoo/writer/DocumentWriterRunner.java
@@ -34,7 +34,7 @@ public class DocumentWriterRunner {
public void writeDocuments() {
long mostRecentStatusMillis = retrieveMostRecentStatusMillis();
for (DocumentWriter dw : this.documentWriters) {
- log.debug("Writing " + dw.getClass().getSimpleName());
+ log.debug("Writing {}", dw.getClass().getSimpleName());
dw.writeDocuments(mostRecentStatusMillis);
}
}
@@ -56,8 +56,7 @@ public class DocumentWriterRunner {
for (DocumentWriter dw : this.documentWriters) {
String statsString = dw.getStatsString();
if (statsString != null) {
- log.info(dw.getClass().getSimpleName() + "\n"
- + statsString);
+ log.info("{}\n{}", dw.getClass().getSimpleName(), statsString);
}
}
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits