mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Logging for plugins.
This commit is contained in:
@@ -4,6 +4,8 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.bluetooth.BluetoothStateException;
|
||||
import javax.bluetooth.DeviceClass;
|
||||
@@ -17,6 +19,9 @@ import net.sf.briar.api.ContactId;
|
||||
|
||||
class BluetoothListener implements DiscoveryListener {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(BluetoothListener.class.getName());
|
||||
|
||||
private static final int[] ATTRIBUTES = { 0x100 }; // Service name
|
||||
|
||||
private final AtomicInteger searches = new AtomicInteger(1);
|
||||
@@ -48,11 +53,10 @@ class BluetoothListener implements DiscoveryListener {
|
||||
// Try to discover the services associated with the UUID
|
||||
try {
|
||||
discoveryAgent.searchServices(ATTRIBUTES, uuids, device, this);
|
||||
searches.incrementAndGet();
|
||||
} catch(BluetoothStateException e) {
|
||||
// FIXME: Logging
|
||||
e.printStackTrace();
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
}
|
||||
searches.incrementAndGet();
|
||||
}
|
||||
|
||||
public void inquiryCompleted(int discoveryType) {
|
||||
|
||||
@@ -9,6 +9,8 @@ import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.bluetooth.BluetoothStateException;
|
||||
import javax.bluetooth.DiscoveryAgent;
|
||||
@@ -33,6 +35,8 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin {
|
||||
public static final int TRANSPORT_ID = 2;
|
||||
|
||||
private static final TransportId id = new TransportId(TRANSPORT_ID);
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(BluetoothPlugin.class.getName());
|
||||
|
||||
private final long pollingInterval;
|
||||
|
||||
@@ -94,7 +98,7 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin {
|
||||
try {
|
||||
localDevice.setDiscoverable(DiscoveryAgent.GIAC);
|
||||
} catch(BluetoothStateException e) {
|
||||
// FIXME: Logging
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
}
|
||||
// Bind the port
|
||||
String url = "btspp://localhost:" + uuid + ";name=" + uuid;
|
||||
@@ -102,7 +106,7 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin {
|
||||
try {
|
||||
scn = (StreamConnectionNotifier) Connector.open(url);
|
||||
} catch(IOException e) {
|
||||
// FIXME: Logging
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
return;
|
||||
}
|
||||
synchronized(this) {
|
||||
@@ -110,7 +114,8 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin {
|
||||
try {
|
||||
scn.close();
|
||||
} catch(IOException e) {
|
||||
// FIXME: Logging
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -152,7 +157,7 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin {
|
||||
try {
|
||||
s = scn.acceptAndOpen();
|
||||
} catch(IOException e) {
|
||||
// FIXME: Logging
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
return;
|
||||
}
|
||||
synchronized(this) {
|
||||
@@ -160,7 +165,8 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin {
|
||||
try {
|
||||
s.close();
|
||||
} catch(IOException e) {
|
||||
// FIXME: Logging
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -243,10 +249,8 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin {
|
||||
listener.wait();
|
||||
}
|
||||
} catch(BluetoothStateException e) {
|
||||
// FIXME: Logging
|
||||
} catch(InterruptedException e) {
|
||||
// FIXME: Logging
|
||||
}
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
} catch(InterruptedException ignored) {}
|
||||
return listener.getUrls();
|
||||
}
|
||||
|
||||
@@ -260,7 +264,7 @@ class BluetoothPlugin extends AbstractPlugin implements StreamTransportPlugin {
|
||||
StreamConnection s = (StreamConnection) Connector.open(url);
|
||||
return new BluetoothTransportConnection(s);
|
||||
} catch(IOException e) {
|
||||
// FIXME: Logging
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.transport.InvalidConfigException;
|
||||
@@ -23,6 +25,9 @@ import org.apache.commons.io.FileSystemUtils;
|
||||
abstract class FilePlugin extends AbstractPlugin
|
||||
implements BatchTransportPlugin {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(FilePlugin.class.getName());
|
||||
|
||||
protected abstract File chooseOutputDirectory();
|
||||
protected abstract void writerFinished(File f);
|
||||
protected abstract void readerFinished(File f);
|
||||
@@ -56,6 +61,7 @@ implements BatchTransportPlugin {
|
||||
OutputStream out = new FileOutputStream(f);
|
||||
return new FileTransportWriter(f, out, capacity, this);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
f.delete();
|
||||
return null;
|
||||
}
|
||||
@@ -102,6 +108,7 @@ implements BatchTransportPlugin {
|
||||
}
|
||||
}
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.TransportId;
|
||||
@@ -18,6 +20,8 @@ implements RemovableDriveMonitor.Callback {
|
||||
public static final int TRANSPORT_ID = 0;
|
||||
|
||||
private static final TransportId id = new TransportId(TRANSPORT_ID);
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(RemovableDrivePlugin.class.getName());
|
||||
|
||||
private final RemovableDriveFinder finder;
|
||||
private final RemovableDriveMonitor monitor;
|
||||
@@ -73,6 +77,7 @@ implements RemovableDriveMonitor.Callback {
|
||||
if(i == -1) return null;
|
||||
return drives.get(i);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.transport.InvalidConfigException;
|
||||
@@ -18,6 +20,9 @@ import net.sf.briar.plugins.AbstractPlugin;
|
||||
abstract class SocketPlugin extends AbstractPlugin
|
||||
implements StreamTransportPlugin {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(SocketPlugin.class.getName());
|
||||
|
||||
// These fields should be accessed with this's lock held
|
||||
protected StreamTransportCallback callback = null;
|
||||
protected ServerSocket socket = null;
|
||||
@@ -62,7 +67,7 @@ implements StreamTransportPlugin {
|
||||
if(addr == null || ss == null) return;
|
||||
ss.bind(addr);
|
||||
} catch(IOException e) {
|
||||
// FIXME: Logging
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
return;
|
||||
}
|
||||
synchronized(this) {
|
||||
@@ -70,7 +75,8 @@ implements StreamTransportPlugin {
|
||||
try {
|
||||
ss.close();
|
||||
} catch(IOException e) {
|
||||
// FIXME: Logging
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -101,7 +107,7 @@ implements StreamTransportPlugin {
|
||||
try {
|
||||
s = ss.accept();
|
||||
} catch(IOException e) {
|
||||
// FIXME: Logging
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
|
||||
return;
|
||||
}
|
||||
synchronized(this) {
|
||||
@@ -109,7 +115,8 @@ implements StreamTransportPlugin {
|
||||
try {
|
||||
s.close();
|
||||
} catch(IOException e) {
|
||||
// FIXME: Logging
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -138,7 +145,8 @@ implements StreamTransportPlugin {
|
||||
try {
|
||||
socket.close();
|
||||
} catch(IOException e) {
|
||||
// FIXME: Logging
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.getMessage());
|
||||
}
|
||||
socket = null;
|
||||
executor.execute(createBinder());
|
||||
|
||||
Reference in New Issue
Block a user