diff --git a/src/main/java/org/ice4j/ice/Component.java b/src/main/java/org/ice4j/ice/Component.java index a306fd38..2c720b9b 100644 --- a/src/main/java/org/ice4j/ice/Component.java +++ b/src/main/java/org/ice4j/ice/Component.java @@ -161,9 +161,11 @@ protected Component(int componentID, this.componentID = componentID; this.parentStream = mediaStream; + Logger agentLogger = mediaStream.getParentAgent().getLogger(); + try { - componentSocket = new ComponentSocket(this); + componentSocket = new ComponentSocket(this, agentLogger); socket = new MultiplexingDatagramSocket(componentSocket); socketWrapper = new IceUdpSocketWrapper(socket); } @@ -172,8 +174,7 @@ protected Component(int componentID, throw new RuntimeException(se); } - logger - = new Logger(classLogger, mediaStream.getParentAgent().getLogger()); + logger = new Logger(classLogger, agentLogger); } /** diff --git a/src/main/java/org/ice4j/ice/ComponentSocket.java b/src/main/java/org/ice4j/ice/ComponentSocket.java index bffde11c..ae4c85f3 100644 --- a/src/main/java/org/ice4j/ice/ComponentSocket.java +++ b/src/main/java/org/ice4j/ice/ComponentSocket.java @@ -24,7 +24,7 @@ import java.net.*; import java.util.*; import java.util.concurrent.*; -import java.util.logging.*; +import org.ice4j.util.*; //Disambiguation /** * Extends {@link MergingDatagramSocket} with functionality specific to @@ -38,8 +38,9 @@ public class ComponentSocket * The {@link Logger} used by the {@link MergingDatagramSocket} class and * its instances for logging output. */ - private static final Logger logger - = Logger.getLogger(MergingDatagramSocket.class.getName()); + private static final java.util.logging.Logger classLogger + = java.util.logging.Logger.getLogger + (MergingDatagramSocket.class.getName()); /** * Controls access to {@link #authorizedAddresses}. @@ -65,15 +66,22 @@ public class ComponentSocket */ private boolean initializedActive = false; + /** + * The {@link Logger} used by {@link MergingDatagramSocket} instances. + */ + private final Logger logger; /** * Initializes a new {@link MergingDatagramSocket} instance. * @throws SocketException */ - ComponentSocket(Component component) + ComponentSocket(Component component, Logger levelDelegate) throws SocketException { + super(levelDelegate); + this.component = component; + this.logger = new Logger(classLogger, levelDelegate); component.getParentStream().addPairChangeListener(this); } diff --git a/src/main/java/org/ice4j/socket/MergingDatagramSocket.java b/src/main/java/org/ice4j/socket/MergingDatagramSocket.java index 098289ab..1027ae15 100644 --- a/src/main/java/org/ice4j/socket/MergingDatagramSocket.java +++ b/src/main/java/org/ice4j/socket/MergingDatagramSocket.java @@ -24,6 +24,7 @@ import java.util.*; import java.util.concurrent.*; import java.util.logging.*; +import org.ice4j.util.Logger; //Disambiguation /** * A {@link DatagramSocket} implementation which merges a set of sockets. @@ -47,8 +48,9 @@ public class MergingDatagramSocket * The {@link Logger} used by the {@link MergingDatagramSocket} class and * its instances for logging output. */ - private static final Logger logger - = Logger.getLogger(MergingDatagramSocket.class.getName()); + private static final java.util.logging.Logger classLogger + = java.util.logging.Logger.getLogger( + MergingDatagramSocket.class.getName()); /** * Used to control access to {@link #socketContainers}. @@ -92,6 +94,10 @@ public class MergingDatagramSocket */ private int numDiscardedPackets = 0; + /** + * The {@link Logger} used by {@link MergingDatagramSocket} instances. + */ + private final Logger logger; /** * Initializes a new {@link MergingDatagramSocket} instance. @@ -99,7 +105,21 @@ public class MergingDatagramSocket */ public MergingDatagramSocket() throws SocketException - {} + { + this(null); + } + + /** + * Initializes a new {@link MergingDatagramSocket} instance. + * @param levelDelegate the {@link Logger} instance which dictates the + * logging level for the new {@link MergingDatagramSocket} instance. + * @throws SocketException + */ + public MergingDatagramSocket(Logger levelDelegate) + throws SocketException + { + logger = new Logger(classLogger, levelDelegate); + } /** * {@inheritDoc}