Introduces a separate log level for each Agent instance.
Makes instances belonging to an Agent use the log level from the Agent instance. The motivation is to disable logging output from Agents created for the purposes of jitsi-videobridge health checks (but not other Agents).
This commit is contained in:
parent
4f946f38a4
commit
dc29172a2c
@ -28,6 +28,7 @@ import java.util.logging.*;
|
|||||||
import org.ice4j.*;
|
import org.ice4j.*;
|
||||||
import org.ice4j.ice.harvest.*;
|
import org.ice4j.ice.harvest.*;
|
||||||
import org.ice4j.stack.*;
|
import org.ice4j.stack.*;
|
||||||
|
import org.ice4j.util.Logger; // Disambiguation.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An <tt>Agent</tt> could be described as the main class (i.e. the chef
|
* An <tt>Agent</tt> could be described as the main class (i.e. the chef
|
||||||
@ -89,11 +90,13 @@ public class Agent
|
|||||||
= new PropertyChangeListener[0];
|
= new PropertyChangeListener[0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <tt>Logger</tt> used by the <tt>Agent</tt> class and its instances
|
* The {@link Logger} used by the {@link Agent} class for logging output.
|
||||||
* for logging output.
|
* Note that this shouldn't be used directly by instances of {@link Agent},
|
||||||
|
* because it doesn't take into account the per-instance log level.
|
||||||
|
* Instances should use {@link #logger} instead.
|
||||||
*/
|
*/
|
||||||
private static final Logger logger
|
private static final java.util.logging.Logger classLogger
|
||||||
= Logger.getLogger(Agent.class.getName());
|
= java.util.logging.Logger.getLogger(Agent.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the {@link PropertyChangeEvent} that we use to deliver
|
* The name of the {@link PropertyChangeEvent} that we use to deliver
|
||||||
@ -287,11 +290,27 @@ public class Agent
|
|||||||
*/
|
*/
|
||||||
private Boolean useHostHarvester = null;
|
private Boolean useHostHarvester = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Logger} used by {@link Agent} instances.
|
||||||
|
*/
|
||||||
|
private final Logger logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty <tt>Agent</tt> with no streams, and no address.
|
* Creates an empty <tt>Agent</tt> with no streams, and no address.
|
||||||
*/
|
*/
|
||||||
public Agent()
|
public Agent()
|
||||||
{
|
{
|
||||||
|
this(Level.INFO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an empty <tt>Agent</tt> with no streams, and no address.
|
||||||
|
* @param loggingLevel the logging level to be used by the agent and all of
|
||||||
|
* its components.
|
||||||
|
*/
|
||||||
|
public Agent(Level loggingLevel)
|
||||||
|
{
|
||||||
|
logger = new Logger(classLogger, loggingLevel);
|
||||||
SecureRandom random = new SecureRandom();
|
SecureRandom random = new SecureRandom();
|
||||||
|
|
||||||
connCheckServer = new ConnectivityCheckServer(this);
|
connCheckServer = new ConnectivityCheckServer(this);
|
||||||
@ -338,7 +357,8 @@ public class Agent
|
|||||||
*/
|
*/
|
||||||
public IceMediaStream createMediaStream(String mediaStreamName)
|
public IceMediaStream createMediaStream(String mediaStreamName)
|
||||||
{
|
{
|
||||||
logger.fine("Create media stream for " + mediaStreamName);
|
logger.debug("Create media stream for " + mediaStreamName);
|
||||||
|
|
||||||
IceMediaStream mediaStream
|
IceMediaStream mediaStream
|
||||||
= new IceMediaStream(Agent.this, mediaStreamName);
|
= new IceMediaStream(Agent.this, mediaStreamName);
|
||||||
|
|
||||||
@ -401,12 +421,6 @@ public class Agent
|
|||||||
|
|
||||||
gatherCandidates(component, preferredPort, minPort, maxPort);
|
gatherCandidates(component, preferredPort, minPort, maxPort);
|
||||||
|
|
||||||
for(Candidate<?> candidate : component.getLocalCandidates())
|
|
||||||
{
|
|
||||||
logger.info("\t" + candidate.getTransportAddress() + " (" +
|
|
||||||
candidate.getType() + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lyubomir: After we've gathered the LocalCandidate for a Component and
|
* Lyubomir: After we've gathered the LocalCandidate for a Component and
|
||||||
* before we've made them available to the caller, we have to make sure
|
* before we've made them available to the caller, we have to make sure
|
||||||
@ -2015,64 +2029,6 @@ public class Agent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* RFC 5245 says: Once ICE processing has reached the Completed state for
|
|
||||||
* all peers for media streams using those candidates, the agent SHOULD
|
|
||||||
* wait an additional three seconds, and then it MAY cease responding to
|
|
||||||
* checks or generating triggered checks on that candidate. It MAY free
|
|
||||||
* the candidate at that time.
|
|
||||||
* <p>
|
|
||||||
* This <tt>TerminationThread</tt> is scheduling such a termination and
|
|
||||||
* garbage collection in three seconds.
|
|
||||||
*/
|
|
||||||
private class TerminationThread
|
|
||||||
extends Thread
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new termination timer.
|
|
||||||
*/
|
|
||||||
private TerminationThread()
|
|
||||||
{
|
|
||||||
super("TerminationThread");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Waits for a period of three seconds (or whatever termination
|
|
||||||
* interval the user has specified) and then moves this <tt>Agent</tt>
|
|
||||||
* into the terminated state and frees all non-nominated candidates.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public synchronized void run()
|
|
||||||
{
|
|
||||||
long terminationDelay
|
|
||||||
= Integer.getInteger(
|
|
||||||
StackProperties.TERMINATION_DELAY,
|
|
||||||
DEFAULT_TERMINATION_DELAY);
|
|
||||||
|
|
||||||
if (terminationDelay >= 0)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
wait(terminationDelay);
|
|
||||||
}
|
|
||||||
catch (InterruptedException ie)
|
|
||||||
{
|
|
||||||
logger.log(
|
|
||||||
Level.FINEST, "Interrupted while waiting. Will "
|
|
||||||
+"speed up termination",
|
|
||||||
ie);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
terminate(IceProcessingState.TERMINATED);
|
|
||||||
|
|
||||||
synchronized (terminationThreadSyncRoot)
|
|
||||||
{
|
|
||||||
terminationThread = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminates this <tt>Agent</tt> by stopping the handling of connectivity
|
* Terminates this <tt>Agent</tt> by stopping the handling of connectivity
|
||||||
@ -2549,4 +2505,87 @@ public class Agent
|
|||||||
{
|
{
|
||||||
this.useHostHarvester = useHostHarvester;
|
this.useHostHarvester = useHostHarvester;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the logging level for this {@link Agent} and its components.
|
||||||
|
* @param level the level to set.
|
||||||
|
*/
|
||||||
|
public void setLoggingLevel(Level level)
|
||||||
|
{
|
||||||
|
logger.setLevel(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the logging level for this {@link Agent} and its components.
|
||||||
|
*/
|
||||||
|
public Level getLoggingLevel()
|
||||||
|
{
|
||||||
|
return logger.getLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return this {@link Agent}'s {@link Logger}.
|
||||||
|
*/
|
||||||
|
protected Logger getLogger()
|
||||||
|
{
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RFC 5245 says: Once ICE processing has reached the Completed state for
|
||||||
|
* all peers for media streams using those candidates, the agent SHOULD
|
||||||
|
* wait an additional three seconds, and then it MAY cease responding to
|
||||||
|
* checks or generating triggered checks on that candidate. It MAY free
|
||||||
|
* the candidate at that time.
|
||||||
|
* <p>
|
||||||
|
* This <tt>TerminationThread</tt> is scheduling such a termination and
|
||||||
|
* garbage collection in three seconds.
|
||||||
|
*/
|
||||||
|
private class TerminationThread
|
||||||
|
extends Thread
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new termination timer.
|
||||||
|
*/
|
||||||
|
private TerminationThread()
|
||||||
|
{
|
||||||
|
super("TerminationThread");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits for a period of three seconds (or whatever termination
|
||||||
|
* interval the user has specified) and then moves this <tt>Agent</tt>
|
||||||
|
* into the terminated state and frees all non-nominated candidates.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public synchronized void run()
|
||||||
|
{
|
||||||
|
long terminationDelay
|
||||||
|
= Integer.getInteger(
|
||||||
|
StackProperties.TERMINATION_DELAY,
|
||||||
|
DEFAULT_TERMINATION_DELAY);
|
||||||
|
|
||||||
|
if (terminationDelay >= 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
wait(terminationDelay);
|
||||||
|
}
|
||||||
|
catch (InterruptedException ie)
|
||||||
|
{
|
||||||
|
logger.log(Level.FINEST, "Interrupted while waiting. Will "
|
||||||
|
+ "speed up termination",
|
||||||
|
ie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
terminate(IceProcessingState.TERMINATED);
|
||||||
|
|
||||||
|
synchronized (terminationThreadSyncRoot)
|
||||||
|
{
|
||||||
|
terminationThread = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,8 @@ package org.ice4j.ice;
|
|||||||
|
|
||||||
import java.beans.*;
|
import java.beans.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.*;
|
|
||||||
|
import org.ice4j.util.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A check list is a list of <tt>CandidatePair</tt>s with a state (i.e. a
|
* A check list is a list of <tt>CandidatePair</tt>s with a state (i.e. a
|
||||||
@ -35,16 +36,31 @@ public class CheckList
|
|||||||
extends Vector<CandidatePair>
|
extends Vector<CandidatePair>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The logger.
|
* The class logger.
|
||||||
|
* Note that this shouldn't be used directly by instances of
|
||||||
|
* {@link CheckList}, because it doesn't take into account the per-instance
|
||||||
|
* log level. Instances should use {@link #logger} instead.
|
||||||
*/
|
*/
|
||||||
private static final Logger logger =
|
private static final java.util.logging.Logger classLogger
|
||||||
Logger.getLogger(CheckList.class.getName());
|
= java.util.logging.Logger.getLogger(CheckList.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A dummy serialization id.
|
* A dummy serialization id.
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the {@link PropertyChangeEvent} that we use to deliver
|
||||||
|
* changes on the state of this check list.
|
||||||
|
*/
|
||||||
|
public static final String PROPERTY_CHECK_LIST_STATE = "CheckListState";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the {@link PropertyChangeEvent} that we use to deliver
|
||||||
|
* changes on the end of checks of this check list.
|
||||||
|
*/
|
||||||
|
public static final String PROPERTY_CHECK_LIST_CHECKS = "CheckListChecks";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The state of this check list.
|
* The state of this check list.
|
||||||
*/
|
*/
|
||||||
@ -78,16 +94,9 @@ public class CheckList
|
|||||||
= new LinkedList<>();
|
= new LinkedList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the {@link PropertyChangeEvent} that we use to deliver
|
* The {@link Logger} used by {@link CheckList} instances.
|
||||||
* changes on the state of this check list.
|
|
||||||
*/
|
*/
|
||||||
public static final String PROPERTY_CHECK_LIST_STATE = "CheckListState";
|
private Logger logger;
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the {@link PropertyChangeEvent} that we use to deliver
|
|
||||||
* changes on the end of checks of this check list.
|
|
||||||
*/
|
|
||||||
public static final String PROPERTY_CHECK_LIST_CHECKS = "CheckListChecks";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a check list with the specified name.
|
* Creates a check list with the specified name.
|
||||||
@ -98,6 +107,8 @@ public class CheckList
|
|||||||
protected CheckList(IceMediaStream parentStream)
|
protected CheckList(IceMediaStream parentStream)
|
||||||
{
|
{
|
||||||
this.parentStream = parentStream;
|
this.parentStream = parentStream;
|
||||||
|
logger
|
||||||
|
= new Logger(classLogger, parentStream.getParentAgent().getLogger());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import java.util.*;
|
|||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
|
||||||
import org.ice4j.*;
|
import org.ice4j.*;
|
||||||
|
import org.ice4j.util.Logger; //Disambiguation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A component is a piece of a media stream requiring a single transport
|
* A component is a piece of a media stream requiring a single transport
|
||||||
@ -38,9 +39,12 @@ public class Component
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Our class logger.
|
* Our class logger.
|
||||||
|
* Note that this shouldn't be used directly by instances of
|
||||||
|
* {@link IceMediaStream}, because it doesn't take into account the
|
||||||
|
* per-instance log level. Instances should use {@link #logger} instead.
|
||||||
*/
|
*/
|
||||||
private static final Logger logger
|
private static final java.util.logging.Logger classLogger
|
||||||
= Logger.getLogger(Component.class.getName());
|
= java.util.logging.Logger.getLogger(Component.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The component ID to use with RTP streams.
|
* The component ID to use with RTP streams.
|
||||||
@ -112,6 +116,11 @@ public class Component
|
|||||||
*/
|
*/
|
||||||
private Candidate<?> defaultRemoteCandidate = null;
|
private Candidate<?> defaultRemoteCandidate = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Logger} used by {@link Component} instances.
|
||||||
|
*/
|
||||||
|
private Logger logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new <tt>Component</tt> with the specified <tt>componentID</tt>
|
* Creates a new <tt>Component</tt> with the specified <tt>componentID</tt>
|
||||||
* as a child of the specified <tt>IceMediaStream</tt>.
|
* as a child of the specified <tt>IceMediaStream</tt>.
|
||||||
@ -126,6 +135,9 @@ public class Component
|
|||||||
// the max value for componentID is 256
|
// the max value for componentID is 256
|
||||||
this.componentID = componentID;
|
this.componentID = componentID;
|
||||||
this.parentStream = mediaStream;
|
this.parentStream = mediaStream;
|
||||||
|
|
||||||
|
logger
|
||||||
|
= new Logger(classLogger, mediaStream.getParentAgent().getLogger());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import org.ice4j.attribute.*;
|
|||||||
import org.ice4j.message.*;
|
import org.ice4j.message.*;
|
||||||
import org.ice4j.socket.*;
|
import org.ice4j.socket.*;
|
||||||
import org.ice4j.stack.*;
|
import org.ice4j.stack.*;
|
||||||
|
import org.ice4j.util.Logger; //Disambiguation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class that will be generating our outgoing connectivity checks and that
|
* The class that will be generating our outgoing connectivity checks and that
|
||||||
@ -39,10 +40,14 @@ class ConnectivityCheckClient
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The <tt>Logger</tt> used by the <tt>ConnectivityCheckClient</tt>
|
* The <tt>Logger</tt> used by the <tt>ConnectivityCheckClient</tt>
|
||||||
* class and its instances for logging output.
|
* class for logging output.
|
||||||
|
* Note that this shouldn't be used directly by instances of
|
||||||
|
* {@link ConnectivityCheckClient}, because it doesn't take into account
|
||||||
|
* the per-instance log level. Instances should use {@link #logger} instead.
|
||||||
*/
|
*/
|
||||||
private static final Logger logger
|
private static final java.util.logging.Logger classLogger
|
||||||
= Logger.getLogger(ConnectivityCheckClient.class.getName());
|
= java.util.logging.Logger.getLogger(
|
||||||
|
ConnectivityCheckClient.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The agent that created us.
|
* The agent that created us.
|
||||||
@ -70,6 +75,11 @@ class ConnectivityCheckClient
|
|||||||
*/
|
*/
|
||||||
private boolean alive = false;
|
private boolean alive = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Logger} used by {@link ConnectivityCheckClient} instances.
|
||||||
|
*/
|
||||||
|
private Logger logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new <tt>ConnectivityCheckClient</tt> setting
|
* Creates a new <tt>ConnectivityCheckClient</tt> setting
|
||||||
* <tt>parentAgent</tt> as the agent that will be used for retrieving
|
* <tt>parentAgent</tt> as the agent that will be used for retrieving
|
||||||
@ -80,6 +90,7 @@ class ConnectivityCheckClient
|
|||||||
public ConnectivityCheckClient(Agent parentAgent)
|
public ConnectivityCheckClient(Agent parentAgent)
|
||||||
{
|
{
|
||||||
this.parentAgent = parentAgent;
|
this.parentAgent = parentAgent;
|
||||||
|
logger = new Logger(classLogger, parentAgent.getLogger());
|
||||||
|
|
||||||
stunStack = this.parentAgent.getStunStack();
|
stunStack = this.parentAgent.getStunStack();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import org.ice4j.attribute.*;
|
|||||||
import org.ice4j.message.*;
|
import org.ice4j.message.*;
|
||||||
import org.ice4j.security.*;
|
import org.ice4j.security.*;
|
||||||
import org.ice4j.stack.*;
|
import org.ice4j.stack.*;
|
||||||
|
import org.ice4j.util.Logger; // Disambiguation.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class that would be handling and responding to incoming connectivity
|
* The class that would be handling and responding to incoming connectivity
|
||||||
@ -39,9 +40,13 @@ class ConnectivityCheckServer
|
|||||||
/**
|
/**
|
||||||
* The <tt>Logger</tt> used by the <tt>ConnectivityCheckServer</tt>
|
* The <tt>Logger</tt> used by the <tt>ConnectivityCheckServer</tt>
|
||||||
* class and its instances for logging output.
|
* class and its instances for logging output.
|
||||||
|
* Note that this shouldn't be used directly by instances of
|
||||||
|
* {@link ConnectivityCheckServer}, because it doesn't take into account
|
||||||
|
* the per-instance log level. Instances should use {@link #logger} instead.
|
||||||
*/
|
*/
|
||||||
private static final Logger logger
|
private static final java.util.logging.Logger classLogger
|
||||||
= Logger.getLogger(ConnectivityCheckServer.class.getName());
|
= java.util.logging.Logger.getLogger(
|
||||||
|
ConnectivityCheckServer.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares <tt>a</tt> and <tt>b</tt> as unsigned long values. Serves the
|
* Compares <tt>a</tt> and <tt>b</tt> as unsigned long values. Serves the
|
||||||
@ -81,6 +86,11 @@ class ConnectivityCheckServer
|
|||||||
*/
|
*/
|
||||||
private boolean alive = false;
|
private boolean alive = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Logger} used by {@link ConnectivityCheckServer} instances.
|
||||||
|
*/
|
||||||
|
private Logger logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new <tt>ConnectivityCheckServer</tt> setting
|
* Creates a new <tt>ConnectivityCheckServer</tt> setting
|
||||||
* <tt>parentAgent</tt> as the agent that will be used for retrieving
|
* <tt>parentAgent</tt> as the agent that will be used for retrieving
|
||||||
@ -91,6 +101,7 @@ class ConnectivityCheckServer
|
|||||||
public ConnectivityCheckServer(Agent parentAgent)
|
public ConnectivityCheckServer(Agent parentAgent)
|
||||||
{
|
{
|
||||||
this.parentAgent = parentAgent;
|
this.parentAgent = parentAgent;
|
||||||
|
logger = new Logger(classLogger, parentAgent.getLogger());
|
||||||
|
|
||||||
stunStack = this.parentAgent.getStunStack();
|
stunStack = this.parentAgent.getStunStack();
|
||||||
stunStack.getCredentialsManager().registerAuthority(this);
|
stunStack.getCredentialsManager().registerAuthority(this);
|
||||||
|
|||||||
@ -19,7 +19,8 @@ package org.ice4j.ice;
|
|||||||
|
|
||||||
import java.beans.*;
|
import java.beans.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.*;
|
|
||||||
|
import org.ice4j.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements ice4j internal nomination strategies.
|
* Implements ice4j internal nomination strategies.
|
||||||
@ -30,10 +31,13 @@ public class DefaultNominator
|
|||||||
implements PropertyChangeListener
|
implements PropertyChangeListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The logger.
|
* The class logger.
|
||||||
|
* Note that this shouldn't be used directly by instances of
|
||||||
|
* {@link DefaultNominator}, because it doesn't take into account the
|
||||||
|
* per-instance log level. Instances should use {@link #logger} instead.
|
||||||
*/
|
*/
|
||||||
private static final Logger logger
|
private static final java.util.logging.Logger classLogger
|
||||||
= Logger.getLogger(DefaultNominator.class.getName());
|
= java.util.logging.Logger.getLogger(DefaultNominator.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Agent that created us.
|
* The Agent that created us.
|
||||||
@ -52,6 +56,11 @@ public class DefaultNominator
|
|||||||
*/
|
*/
|
||||||
private final Map<String, TimerTask> validatedCandidates = new HashMap<>();
|
private final Map<String, TimerTask> validatedCandidates = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Logger} used by {@link DefaultNominator} instances.
|
||||||
|
*/
|
||||||
|
private Logger logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of this nominator using <tt>parentAgent</tt> as
|
* Creates a new instance of this nominator using <tt>parentAgent</tt> as
|
||||||
* a reference to the <tt>Agent</tt> instance that we should use to
|
* a reference to the <tt>Agent</tt> instance that we should use to
|
||||||
@ -62,6 +71,7 @@ public class DefaultNominator
|
|||||||
public DefaultNominator(Agent parentAgent)
|
public DefaultNominator(Agent parentAgent)
|
||||||
{
|
{
|
||||||
this.parentAgent = parentAgent;
|
this.parentAgent = parentAgent;
|
||||||
|
logger = new Logger(classLogger, parentAgent.getLogger());
|
||||||
parentAgent.addStateChangeListener(this);
|
parentAgent.addStateChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,8 +20,10 @@ package org.ice4j.ice;
|
|||||||
import java.beans.*;
|
import java.beans.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.ice4j.*;
|
import org.ice4j.*;
|
||||||
|
import org.ice4j.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class represents a media stream from the ICE perspective, i.e. a
|
* The class represents a media stream from the ICE perspective, i.e. a
|
||||||
@ -33,9 +35,12 @@ import org.ice4j.*;
|
|||||||
public class IceMediaStream
|
public class IceMediaStream
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Our class logger.
|
* Our class logger
|
||||||
|
* Note that this shouldn't be used directly by instances of
|
||||||
|
* {@link IceMediaStream}, because it doesn't take into account the
|
||||||
|
* per-instance log level. Instances should use {@link #logger} instead.
|
||||||
*/
|
*/
|
||||||
private static final Logger logger =
|
private static final Logger classLogger =
|
||||||
Logger.getLogger(IceMediaStream.class.getName());
|
Logger.getLogger(IceMediaStream.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,6 +136,11 @@ public class IceMediaStream
|
|||||||
*/
|
*/
|
||||||
private String remotePassword = null;
|
private String remotePassword = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Logger} used by {@link IceMediaStream} instances.
|
||||||
|
*/
|
||||||
|
private org.ice4j.util.Logger logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a new <tt>IceMediaStream</tt> object.
|
* Initializes a new <tt>IceMediaStream</tt> object.
|
||||||
*
|
*
|
||||||
@ -140,6 +150,7 @@ public class IceMediaStream
|
|||||||
*/
|
*/
|
||||||
protected IceMediaStream(Agent parentAgent, String name)
|
protected IceMediaStream(Agent parentAgent, String name)
|
||||||
{
|
{
|
||||||
|
logger = new org.ice4j.util.Logger(classLogger, parentAgent.getLogger());
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.parentAgent = parentAgent;
|
this.parentAgent = parentAgent;
|
||||||
checkList = new CheckList(this);
|
checkList = new CheckList(this);
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import java.util.logging.*;
|
|||||||
import org.ice4j.*;
|
import org.ice4j.*;
|
||||||
import org.ice4j.socket.*;
|
import org.ice4j.socket.*;
|
||||||
import org.ice4j.stack.*;
|
import org.ice4j.stack.*;
|
||||||
|
import org.ice4j.util.Logger; // Disambiguation.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <tt>LocalCandidate</tt>s are obtained by an agent for every stream component
|
* <tt>LocalCandidate</tt>s are obtained by an agent for every stream component
|
||||||
@ -35,6 +36,16 @@ import org.ice4j.stack.*;
|
|||||||
public abstract class LocalCandidate
|
public abstract class LocalCandidate
|
||||||
extends Candidate<LocalCandidate>
|
extends Candidate<LocalCandidate>
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* The <tt>Logger</tt> used by the <tt>LocalCandidate</tt> class for logging
|
||||||
|
* output.
|
||||||
|
* Note that this shouldn't be used directly by instances of
|
||||||
|
* {@link DefaultNominator}, because it doesn't take into account the
|
||||||
|
* per-instance log level. Instances should use {@link #logger} instead.
|
||||||
|
*/
|
||||||
|
private static final java.util.logging.Logger classLogger
|
||||||
|
= java.util.logging.Logger.getLogger(HostCandidate.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of method used to discover this candidate ("host", "upnp", "stun
|
* The type of method used to discover this candidate ("host", "upnp", "stun
|
||||||
* peer reflexive", "stun server reflexive", "turn relayed", "google turn
|
* peer reflexive", "stun server reflexive", "turn relayed", "google turn
|
||||||
@ -53,11 +64,9 @@ public abstract class LocalCandidate
|
|||||||
private boolean isSSL = false;
|
private boolean isSSL = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <tt>Logger</tt> used by the <tt>LocalCandidate</tt> class and its
|
* The {@link Logger} used by {@link LocalCandidate} instances.
|
||||||
* instances for logging output.
|
|
||||||
*/
|
*/
|
||||||
private static final Logger logger
|
private Logger logger;
|
||||||
= Logger.getLogger(HostCandidate.class.getName());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a <tt>LocalCandidate</tt> instance for the specified transport
|
* Creates a <tt>LocalCandidate</tt> instance for the specified transport
|
||||||
@ -84,6 +93,10 @@ public abstract class LocalCandidate
|
|||||||
LocalCandidate relatedCandidate)
|
LocalCandidate relatedCandidate)
|
||||||
{
|
{
|
||||||
super(transportAddress, parentComponent, type, relatedCandidate);
|
super(transportAddress, parentComponent, type, relatedCandidate);
|
||||||
|
logger
|
||||||
|
= new Logger(classLogger,
|
||||||
|
parentComponent.
|
||||||
|
getParentStream().getParentAgent().getLogger());
|
||||||
this.extendedType = extendedType;
|
this.extendedType = extendedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import java.net.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
import java.util.logging.Logger; // Disambiguation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A harvester implementation which binds to a single <tt>DatagramSocket</tt>
|
* A harvester implementation which binds to a single <tt>DatagramSocket</tt>
|
||||||
|
|||||||
234
src/main/java/org/ice4j/util/Logger.java
Normal file
234
src/main/java/org/ice4j/util/Logger.java
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
/*
|
||||||
|
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
|
||||||
|
*
|
||||||
|
* Copyright @ 2015 Atlassian Pty Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.ice4j.util;
|
||||||
|
|
||||||
|
import java.util.logging.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements a logger, which delegates to a {@link java.util.logging.Logger}
|
||||||
|
* instance, but maintains its own logging level.
|
||||||
|
*
|
||||||
|
* @author Boris Grozev
|
||||||
|
*/
|
||||||
|
public class Logger
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The level of this logger.
|
||||||
|
*/
|
||||||
|
private Level level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The underlying {@link java.util.logging.Logger} instance to which logging
|
||||||
|
* is delegated.
|
||||||
|
*/
|
||||||
|
private java.util.logging.Logger delegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Logger} instance (if any) which provides the log level of this
|
||||||
|
* instance.
|
||||||
|
*/
|
||||||
|
private Logger levelDelegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes a new {@link Logger} instance with a given delegate and a
|
||||||
|
* given log level.
|
||||||
|
* @param delegate the delegate.
|
||||||
|
* @param level the log level.
|
||||||
|
*/
|
||||||
|
public Logger(java.util.logging.Logger delegate, Level level)
|
||||||
|
{
|
||||||
|
this.delegate = delegate;
|
||||||
|
this.level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes a new {@link Logger} instance with a given delegate and which
|
||||||
|
* uses the log level from another {@link Logger} instance.
|
||||||
|
* @param delegate the delegate.
|
||||||
|
* @param levelDelegate the {@link Logger} instance whose log level will be
|
||||||
|
* used.
|
||||||
|
*/
|
||||||
|
public Logger(java.util.logging.Logger delegate, Logger levelDelegate)
|
||||||
|
{
|
||||||
|
this.delegate = delegate;
|
||||||
|
this.levelDelegate = levelDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the logging {@link Level} for this {@link Logger}.
|
||||||
|
* @param level the level to set.
|
||||||
|
*/
|
||||||
|
public void setLevel(Level level)
|
||||||
|
{
|
||||||
|
this.level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the logging {@link Level} configured for this {@link Logger}.
|
||||||
|
*/
|
||||||
|
public Level getLevel()
|
||||||
|
{
|
||||||
|
return levelDelegate != null ? levelDelegate.getLevel() : level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether messages with a particular level should be logged
|
||||||
|
* according to the log level configured for this {@link Logger.}
|
||||||
|
* @param level the log level.
|
||||||
|
*/
|
||||||
|
public boolean isLoggable(Level level)
|
||||||
|
{
|
||||||
|
Level currentLevel
|
||||||
|
= levelDelegate != null ? levelDelegate.getLevel() : this.level;
|
||||||
|
int levelValue = currentLevel.intValue();
|
||||||
|
|
||||||
|
return level.intValue() >= levelValue
|
||||||
|
&& levelValue != Level.OFF.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a message at a given level, if that level is loggable according to
|
||||||
|
* the log level configured by this instance.
|
||||||
|
* @param level the level at which to log the message.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*/
|
||||||
|
public void log(Level level, String msg)
|
||||||
|
{
|
||||||
|
if (isLoggable(level))
|
||||||
|
{
|
||||||
|
delegate.log(level, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a message at a given level, if that level is loggable according to
|
||||||
|
* the log level configured by this instance.
|
||||||
|
* @param level the level at which to log the message.
|
||||||
|
* @param msg the message to log.
|
||||||
|
* @param thrown a {@link Throwable} associated with log message.
|
||||||
|
*/
|
||||||
|
public void log(Level level, String msg, Throwable thrown)
|
||||||
|
{
|
||||||
|
if (isLoggable(level))
|
||||||
|
{
|
||||||
|
delegate.log(level, msg, thrown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a message with level {@link Level.SEVERE}, if that level is
|
||||||
|
* loggable according to the log level configured for this {@link Logger}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*/
|
||||||
|
public void severe(String msg)
|
||||||
|
{
|
||||||
|
log(Level.SEVERE, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a message with level {@link Level.WARNING}, if that level is
|
||||||
|
* loggable according to the log level configured for this {@link Logger}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*/
|
||||||
|
public void warning(String msg)
|
||||||
|
{
|
||||||
|
log(Level.WARNING, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a message with level {@link Level.INFO}, if that level is
|
||||||
|
* loggable according to the log level configured for this {@link Logger}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*/
|
||||||
|
public void info(String msg)
|
||||||
|
{
|
||||||
|
log(Level.INFO, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a message with level {@link Level.CONFIG}, if that level is
|
||||||
|
* loggable according to the log level configured for this {@link Logger}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*/
|
||||||
|
public void config(String msg)
|
||||||
|
{
|
||||||
|
log(Level.CONFIG, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a message with level {@link Level.FINE}, if that level is
|
||||||
|
* loggable according to the log level configured for this {@link Logger}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*/
|
||||||
|
public void fine(String msg)
|
||||||
|
{
|
||||||
|
log(Level.FINE, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a message with level {@link Level.FINER}, if that level is
|
||||||
|
* loggable according to the log level configured for this {@link Logger}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*/
|
||||||
|
public void finer(String msg)
|
||||||
|
{
|
||||||
|
log(Level.FINER, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a message with level {@link Level.FINEST}, if that level is
|
||||||
|
* loggable according to the log level configured for this {@link Logger}.
|
||||||
|
* @param msg the message to log.
|
||||||
|
*/
|
||||||
|
public void finest(String msg)
|
||||||
|
{
|
||||||
|
log(Level.FINEST, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An alias for {@link #fine(String)}.
|
||||||
|
*/
|
||||||
|
public void debug(String msg)
|
||||||
|
{
|
||||||
|
fine(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An alias for {@link #warning(String)}.
|
||||||
|
*/
|
||||||
|
public void warn(String msg)
|
||||||
|
{
|
||||||
|
warning(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An alias for {@link #severe(String)}.
|
||||||
|
*/
|
||||||
|
public void error(String msg)
|
||||||
|
{
|
||||||
|
severe(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An alias for {@link #finest(String)}.
|
||||||
|
*/
|
||||||
|
public void trace(String msg)
|
||||||
|
{
|
||||||
|
finest(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -17,7 +17,7 @@ package org.ice4j.util;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.Logger; // Disambiguation.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract queue of packets. This is meant to eventually be able to be used
|
* An abstract queue of packets. This is meant to eventually be able to be used
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
package org.ice4j.util;
|
package org.ice4j.util;
|
||||||
|
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
import java.util.logging.Logger; // Disambiguation.
|
||||||
|
|
||||||
public class QueueStatistics
|
public class QueueStatistics
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user