Skip to content

Commit

Permalink
log: Uses the parent Agent's log level.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrozev committed Dec 9, 2016
1 parent 9a2fe50 commit 75e8948
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/main/java/org/ice4j/ice/Component.java
Expand Up @@ -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);
}
Expand All @@ -172,8 +174,7 @@ protected Component(int componentID,
throw new RuntimeException(se);
}

logger
= new Logger(classLogger, mediaStream.getParentAgent().getLogger());
logger = new Logger(classLogger, agentLogger);
}

/**
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/org/ice4j/ice/ComponentSocket.java
Expand Up @@ -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
Expand All @@ -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}.
Expand All @@ -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);
}

Expand Down
26 changes: 23 additions & 3 deletions src/main/java/org/ice4j/socket/MergingDatagramSocket.java
Expand Up @@ -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.
Expand All @@ -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}.
Expand Down Expand Up @@ -92,14 +94,32 @@ 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.
* @throws SocketException
*/
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}
Expand Down

0 comments on commit 75e8948

Please sign in to comment.