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