From 814167613ccc4abd965e0bdb97fdeba4ca4a33c1 Mon Sep 17 00:00:00 2001
From: akwizgran <akwizgran@users.sourceforge.net>
Date: Thu, 13 Mar 2014 09:37:30 +0000
Subject: [PATCH] Verbose logging of Tor connections, streams and circuits.

---
 .../org/briarproject/plugins/tor/TorPlugin.java | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/briar-android/src/org/briarproject/plugins/tor/TorPlugin.java b/briar-android/src/org/briarproject/plugins/tor/TorPlugin.java
index 18aa760104..371f74d824 100644
--- a/briar-android/src/org/briarproject/plugins/tor/TorPlugin.java
+++ b/briar-android/src/org/briarproject/plugins/tor/TorPlugin.java
@@ -57,6 +57,9 @@ class TorPlugin implements DuplexPlugin, EventHandler {
 
 	static final TransportId ID = new TransportId("tor");
 
+	private static final String[] EVENTS = { 
+		"CIRC", "STREAM", "ORCONN", "NOTICE", "WARN", "ERR"
+	};
 	private static final int SOCKS_PORT = 59050, CONTROL_PORT = 59051;
 	private static final int COOKIE_TIMEOUT = 3000; // Milliseconds
 	private static final int HOSTNAME_TIMEOUT = 30 * 1000; // Milliseconds
@@ -199,7 +202,7 @@ class TorPlugin implements DuplexPlugin, EventHandler {
 		controlConnection.authenticate(read(cookieFile));
 		// Register to receive events from the Tor process
 		controlConnection.setEventHandler(this);
-		controlConnection.setEvents(Arrays.asList("NOTICE", "WARN", "ERR"));
+		controlConnection.setEvents(Arrays.asList(EVENTS));
 		// Register to receive network status events
 		networkStateReceiver = new NetworkStateReceiver();
 		IntentFilter filter = new IntentFilter(CONNECTIVITY_ACTION);
@@ -599,11 +602,17 @@ class TorPlugin implements DuplexPlugin, EventHandler {
 		throw new UnsupportedOperationException();
 	}
 
-	public void circuitStatus(String status, String circID, String path) {}
+	public void circuitStatus(String status, String id, String path) {
+		if(LOG.isLoggable(INFO)) LOG.info("Circuit " + id + " " + status);
+	}
 
-	public void streamStatus(String status, String streamID, String target) {}
+	public void streamStatus(String status, String id, String target) {
+		if(LOG.isLoggable(INFO)) LOG.info("Stream " + id + " " + status);
+	}
 
-	public void orConnStatus(String status, String orName) {}
+	public void orConnStatus(String status, String orName) {
+		if(LOG.isLoggable(INFO)) LOG.info("OR connection " + status);
+	}
 
 	public void bandwidthUsed(long read, long written) {}
 
-- 
GitLab