use the jitsi-utils logger (#186)

* use new logger in agent

* use new logger in component, componentsocket, icemediastream, mergingdatagramsocket

* use new logger in localcandidate

* use new logger in checklist

* use new logger in defaultnominator

* use new logger in connectivitycheckclient, connectivitycheckserver

* fix typo, allow taking in a parent logger

* use jitsi-utils

* clean up uses of old logger and remove it
This commit is contained in:
bbaldino 2019-09-19 08:11:18 -07:00 committed by GitHub
parent 43fa07d9a5
commit e854e4efaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 177 additions and 509 deletions

21
pom.xml
View File

@ -35,6 +35,12 @@
<artifactId>weupnp</artifactId> <artifactId>weupnp</artifactId>
<version>0.1.4</version> <version>0.1.4</version>
</dependency> </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jitsi-utils</artifactId>
<version>1.0-12-gcdf6537</version>
</dependency>
<!-- test --> <!-- test -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -249,4 +255,19 @@
</build> </build>
</profile> </profile>
</profiles> </profiles>
<repositories>
<repository>
<id>jitsi-maven-repository-releases</id>
<layout>default</layout>
<name>Jitsi Maven Repository (Releases)</name>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>https://github.com/jitsi/jitsi-maven-repository/raw/master/releases/</url>
</repository>
</repositories>
</project> </project>

View File

@ -31,7 +31,9 @@ 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.*; import org.ice4j.util.*;
import org.ice4j.util.Logger; // Disambiguation. import org.jitsi.utils.collections.*;
import org.jitsi.utils.logging2.*;
import org.jitsi.utils.logging2.Logger;
/** /**
* 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
@ -343,7 +345,12 @@ public class Agent
*/ */
public Agent() public Agent()
{ {
this(Level.INFO, null); this(null, null);
}
public Agent(Logger parentLogger)
{
this(null, parentLogger);
} }
/** /**
@ -351,33 +358,24 @@ public class Agent
* @param ufragPrefix an optional prefix to the generated local ICE username * @param ufragPrefix an optional prefix to the generated local ICE username
* fragment. * fragment.
*/ */
public Agent(String ufragPrefix) public Agent(String ufragPrefix, Logger parentLogger)
{ {
this(Level.INFO, ufragPrefix);
}
/**
* 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)
{
this(loggingLevel, null);
}
/**
* 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.
* @param ufragPrefix an optional prefix to the generated local ICE username
* fragment.
*/
public Agent(Level loggingLevel, String ufragPrefix)
{
logger = new Logger(classLogger, loggingLevel);
SecureRandom random = new SecureRandom(); SecureRandom random = new SecureRandom();
String ufrag = ufragPrefix == null ? "" : ufragPrefix;
ufrag += new BigInteger(24, random).toString(32);
ufrag += BigInteger.valueOf(System.currentTimeMillis()).toString(32);
ufrag = ensureIceAttributeLength(ufrag, /* min */ 4, /* max */ 256);
this.ufrag = ufrag;
if (parentLogger != null)
{
logger = parentLogger.createChildLogger(this.getClass().getName(), JMap.of("ufrag", this.ufrag));
}
else
{
logger = new LoggerImpl(Agent.class.getName(), new LogContext(JMap.of("ufrag", this.ufrag)));
}
connCheckServer = new ConnectivityCheckServer(this); connCheckServer = new ConnectivityCheckServer(this);
connCheckClient = new ConnectivityCheckClient( connCheckClient = new ConnectivityCheckClient(
this, agentTasksScheduler, agentTasksExecutor); this, agentTasksScheduler, agentTasksExecutor);
@ -389,11 +387,6 @@ public class Agent
if (StackProperties.getString(StackProperties.SOFTWARE) == null) if (StackProperties.getString(StackProperties.SOFTWARE) == null)
System.setProperty(StackProperties.SOFTWARE, "ice4j.org"); System.setProperty(StackProperties.SOFTWARE, "ice4j.org");
String ufrag = ufragPrefix == null ? "" : ufragPrefix;
ufrag += new BigInteger(24, random).toString(32);
ufrag += BigInteger.valueOf(System.currentTimeMillis()).toString(32);
ufrag = ensureIceAttributeLength(ufrag, /* min */ 4, /* max */ 256);
this.ufrag = ufrag;
password password
= ensureIceAttributeLength( = ensureIceAttributeLength(
@ -409,10 +402,7 @@ public class Agent
addCandidateHarvester(harvester); addCandidateHarvester(harvester);
} }
if (logger.isLoggable(Level.FINE)) logger.debug(() -> "Created a new Agent");
{
logger.fine("Created a new Agent, ufrag=" + ufrag);
}
} }
/** /**
@ -434,7 +424,7 @@ public class Agent
*/ */
public IceMediaStream createMediaStream(String mediaStreamName) public IceMediaStream createMediaStream(String mediaStreamName)
{ {
logger.debug("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);
@ -679,7 +669,7 @@ public class Agent
else else
{ {
if (hostHarvesters.isEmpty()) if (hostHarvesters.isEmpty())
logger.warning("No host harvesters available!"); logger.warn("No host harvesters available!");
} }
for (CandidateHarvester harvester : hostHarvesters) for (CandidateHarvester harvester : hostHarvesters)
@ -688,7 +678,7 @@ public class Agent
} }
if (component.getLocalCandidateCount() == 0) if (component.getLocalCandidateCount() == 0)
logger.warning("Failed to gather any host candidates!"); logger.warn("Failed to gather any host candidates!");
//in case we are not trickling, apply other harvesters here //in case we are not trickling, apply other harvesters here
if (!isTrickling()) if (!isTrickling())
@ -697,7 +687,7 @@ public class Agent
harvesters.harvest(component); harvesters.harvest(component);
} }
logger.fine("Candidate count in first harvest: " + logger.debug(() -> "Candidate count in first harvest: " +
component.getLocalCandidateCount()); component.getLocalCandidateCount());
// Emil: Because of trickle, we now assign foundations, compute // Emil: Because of trickle, we now assign foundations, compute
@ -733,7 +723,7 @@ public class Agent
if (harvestingStarted) if (harvestingStarted)
{ {
logger.warning( logger.warn(
"Hmmm ... why are you harvesting twice? You shouldn't be!"); "Hmmm ... why are you harvesting twice? You shouldn't be!");
} }
@ -1102,7 +1092,7 @@ public class Agent
if (stream == null) if (stream == null)
{ {
ret = null; ret = null;
logger.warning( logger.warn(
"Agent contains no IceMediaStream with name " + media "Agent contains no IceMediaStream with name " + media
+ "!"); + "!");
} }
@ -1113,7 +1103,7 @@ public class Agent
if (remoteUfrag == null) if (remoteUfrag == null)
{ {
ret = null; ret = null;
logger.warning( logger.warn(
"Remote ufrag of IceMediaStream with name " + media "Remote ufrag of IceMediaStream with name " + media
+ " is null!"); + " is null!");
} }
@ -1660,7 +1650,7 @@ public class Agent
CandidatePair triggeredPair CandidatePair triggeredPair
= createCandidatePair(localCandidate, remoteCandidate); = createCandidatePair(localCandidate, remoteCandidate);
logger.fine("set use-candidate " + useCandidate + " for pair " + logger.debug(() -> "set use-candidate " + useCandidate + " for pair " +
triggeredPair.toShortString()); triggeredPair.toShortString());
if (useCandidate) if (useCandidate)
{ {
@ -1671,7 +1661,7 @@ public class Agent
{ {
if (state == IceProcessingState.WAITING) if (state == IceProcessingState.WAITING)
{ {
logger.fine("Receive STUN checks before our ICE has started"); logger.debug(() -> "Receive STUN checks before our ICE has started");
//we are not started yet so we'd better wait until we get the //we are not started yet so we'd better wait until we get the
//remote candidates in case we are holding to a new PR one. //remote candidates in case we are holding to a new PR one.
this.preDiscoveredPairsQueue.add(triggeredPair); this.preDiscoveredPairsQueue.add(triggeredPair);
@ -1682,12 +1672,8 @@ public class Agent
} }
else //Running, Connected or Terminated. else //Running, Connected or Terminated.
{ {
if (logger.isLoggable(Level.FINE)) logger.debug(() -> "Received check from "
{ + triggeredPair.toShortString() + " triggered a check.");
logger.debug("Received check from "
+ triggeredPair.toShortString() + " triggered a check. "
+ "Local ufrag " + getLocalUfrag());
}
// We have been started, and have not failed (yet). If this is // We have been started, and have not failed (yet). If this is
// a new pair, handle it (even if we have already completed). // a new pair, handle it (even if we have already completed).
@ -1735,7 +1721,7 @@ public class Agent
//7.2.1.5. Updating the Nominated Flag //7.2.1.5. Updating the Nominated Flag
if (!isControlling() && useCand) if (!isControlling() && useCand)
{ {
logger.fine("update nominated flag"); logger.debug(() -> "update nominated flag");
// If the Binding request received by the agent had the // If the Binding request received by the agent had the
// USE-CANDIDATE attribute set, and the agent is in the // USE-CANDIDATE attribute set, and the agent is in the
// controlled role, the agent looks at the state of the // controlled role, the agent looks at the state of the
@ -1943,7 +1929,7 @@ public class Agent
if (!atLeastOneListSucceeded) if (!atLeastOneListSucceeded)
{ {
//all lists ended but none succeeded. No love today ;( //all lists ended but none succeeded. No love today ;(
if (logger.isLoggable(Level.INFO)) if (logger.isInfoEnabled())
{ {
if (connCheckClient.isAlive() if (connCheckClient.isAlive()
|| connCheckServer.isAlive()) || connCheckServer.isAlive())
@ -2344,7 +2330,7 @@ public class Agent
*/ */
public void free() public void free()
{ {
logger.fine("Free ICE agent"); logger.debug(() -> "Free ICE agent");
shutdown = true; shutdown = true;
@ -2380,17 +2366,17 @@ public class Agent
// Free its IceMediaStreams, Components and Candidates. // Free its IceMediaStreams, Components and Candidates.
boolean interrupted = false; boolean interrupted = false;
logger.fine("remove streams"); logger.debug(() -> "remove streams");
for (IceMediaStream stream : getStreams()) for (IceMediaStream stream : getStreams())
{ {
try try
{ {
removeStream(stream); removeStream(stream);
logger.fine("remove stream " + stream.getName()); logger.debug("remove stream " + stream.getName());
} }
catch (Throwable t) catch (Throwable t)
{ {
logger.fine( logger.debug(() ->
"remove stream " + stream.getName() + " failed: " + t); "remove stream " + stream.getName() + " failed: " + t);
if (t instanceof InterruptedException) if (t instanceof InterruptedException)
interrupted = true; interrupted = true;
@ -2403,7 +2389,7 @@ public class Agent
getStunStack().shutDown(); getStunStack().shutDown();
logger.fine("ICE agent freed"); logger.debug(() -> "ICE agent freed");
} }
/** /**
@ -2738,7 +2724,7 @@ public class Agent
} }
catch (Exception e) catch (Exception e)
{ {
logger.log(Level.WARNING, "Error while sending keep alive", e); logger.warn("Error while sending keep alive", e);
} }
} }

View File

@ -17,11 +17,11 @@
*/ */
package org.ice4j.ice; package org.ice4j.ice;
import org.jitsi.utils.logging2.*;
import java.beans.*; import java.beans.*;
import java.util.*; import java.util.*;
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
* <tt>CheckListState</tt>). The pairs in a check list are those that an ICE * <tt>CheckListState</tt>). The pairs in a check list are those that an ICE
@ -35,15 +35,6 @@ import org.ice4j.util.Logger;
public class CheckList public class CheckList
extends Vector<CandidatePair> extends Vector<CandidatePair>
{ {
/**
* 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 java.util.logging.Logger classLogger
= java.util.logging.Logger.getLogger(CheckList.class.getName());
/** /**
* A dummy serialization id. * A dummy serialization id.
*/ */
@ -107,8 +98,7 @@ public class CheckList
protected CheckList(IceMediaStream parentStream) protected CheckList(IceMediaStream parentStream)
{ {
this.parentStream = parentStream; this.parentStream = parentStream;
logger logger = parentStream.getLogger().createChildLogger(this.getClass().getName());
= new Logger(classLogger, parentStream.getParentAgent().getLogger());
} }
/** /**

View File

@ -22,11 +22,11 @@ import java.io.*;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.logging.*;
import org.ice4j.*; import org.ice4j.*;
import org.ice4j.socket.*; import org.ice4j.socket.*;
import org.ice4j.util.Logger; //Disambiguation import org.jitsi.utils.collections.*;
import org.jitsi.utils.logging2.*;
/** /**
* 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
@ -43,15 +43,6 @@ import org.ice4j.util.Logger; //Disambiguation
public class Component public class Component
implements PropertyChangeListener implements PropertyChangeListener
{ {
/**
* 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.updateRemoteCandidates Instances should use {@link #logger} instead.
*/
private static final java.util.logging.Logger classLogger
= java.util.logging.Logger.getLogger(Component.class.getName());
/** /**
* The component ID to use with RTP streams. * The component ID to use with RTP streams.
*/ */
@ -175,9 +166,10 @@ public class Component
*/ */
protected Component(int componentID, protected Component(int componentID,
IceMediaStream mediaStream, IceMediaStream mediaStream,
KeepAliveStrategy keepAliveStrategy) KeepAliveStrategy keepAliveStrategy,
Logger parentLogger)
{ {
this(componentID, mediaStream, keepAliveStrategy, true); this(componentID, mediaStream, keepAliveStrategy, true, parentLogger);
} }
/** /**
@ -192,21 +184,24 @@ public class Component
protected Component(int componentID, protected Component(int componentID,
IceMediaStream mediaStream, IceMediaStream mediaStream,
KeepAliveStrategy keepAliveStrategy, KeepAliveStrategy keepAliveStrategy,
boolean useComponentSocket) boolean useComponentSocket,
Logger parentLogger)
{ {
// 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;
this.keepAliveStrategy this.keepAliveStrategy
= Objects.requireNonNull(keepAliveStrategy, "keepAliveStrategy"); = Objects.requireNonNull(keepAliveStrategy, "keepAliveStrategy");
this.logger = parentLogger.createChildLogger(
Logger agentLogger = mediaStream.getParentAgent().getLogger(); this.getClass().getName(),
JMap.of("componentId", Integer.toString(componentID))
);
if (useComponentSocket) if (useComponentSocket)
{ {
try try
{ {
componentSocket = new ComponentSocket(this, agentLogger); componentSocket = new ComponentSocket(this, logger);
socket = new MultiplexingDatagramSocket(componentSocket); socket = new MultiplexingDatagramSocket(componentSocket);
socketWrapper = new IceUdpSocketWrapper(socket); socketWrapper = new IceUdpSocketWrapper(socket);
} }
@ -223,7 +218,6 @@ public class Component
} }
mediaStream.addPairChangeListener(this); mediaStream.addPairChangeListener(this);
logger = new Logger(classLogger, agentLogger);
} }
/** /**
@ -694,11 +688,7 @@ public class Component
&& (cand.getPriority() >= cand2.getPriority())) && (cand.getPriority() >= cand2.getPriority()))
{ {
localCandidates.remove(j); localCandidates.remove(j);
if (logger.isLoggable(Level.FINEST)) logger.trace(() -> "eliminating redundant cand: "+ cand2);
{
logger.finest(
"eliminating redundant cand: "+ cand2);
}
} }
else else
j++; j++;
@ -899,12 +889,7 @@ public class Component
*/ */
if (t instanceof ThreadDeath) if (t instanceof ThreadDeath)
throw (ThreadDeath) t; throw (ThreadDeath) t;
if (logger.isLoggable(Level.INFO)) logger.info(() -> "Failed to free LocalCandidate: " + localCandidate);
{
logger.log(
Level.INFO,
"Failed to free LocalCandidate: " + localCandidate);
}
} }
} }
@ -1017,7 +1002,7 @@ public class Component
* parent of this component. * parent of this component.
* @return Component * @return Component
*/ */
public static Component build(int componentID, IceMediaStream mediaStream) public static Component build(int componentID, IceMediaStream mediaStream, Logger parentLogger)
{ {
return return
new Component( new Component(
@ -1025,7 +1010,9 @@ public class Component
mediaStream, mediaStream,
KeepAliveStrategy.SELECTED_ONLY, KeepAliveStrategy.SELECTED_ONLY,
StackProperties.getBoolean( StackProperties.getBoolean(
StackProperties.USE_COMPONENT_SOCKET, true)); StackProperties.USE_COMPONENT_SOCKET, true),
parentLogger
);
} }
/** /**
@ -1136,4 +1123,9 @@ public class Component
keepAlivePairs.add(pair); keepAlivePairs.add(pair);
} }
} }
public Logger getLogger()
{
return logger;
}
} }

View File

@ -33,14 +33,6 @@ public class ComponentSocket
extends MergingDatagramSocket extends MergingDatagramSocket
implements PropertyChangeListener implements PropertyChangeListener
{ {
/**
* The {@link Logger} used by the {@link MergingDatagramSocket} class and
* its instances for logging output.
*/
private static final java.util.logging.Logger classLogger
= java.util.logging.Logger.getLogger
(MergingDatagramSocket.class.getName());
/** /**
* Controls access to {@link #authorizedAddresses}. * Controls access to {@link #authorizedAddresses}.
*/ */
@ -68,22 +60,16 @@ public class ComponentSocket
*/ */
private final Object initializedActiveSyncRoot = new Object(); private final Object initializedActiveSyncRoot = new Object();
/**
* The {@link Logger} used by {@link MergingDatagramSocket} instances.
*/
private final Logger logger;
/** /**
* Initializes a new {@link MergingDatagramSocket} instance. * Initializes a new {@link MergingDatagramSocket} instance.
* @throws SocketException * @throws SocketException
*/ */
ComponentSocket(Component component, Logger levelDelegate) ComponentSocket(Component component, org.jitsi.utils.logging2.Logger parentLogger)
throws SocketException throws SocketException
{ {
super(levelDelegate); super(parentLogger);
this.component = component; this.component = component;
this.logger = new Logger(classLogger, levelDelegate);
component.getParentStream().addPairChangeListener(this); component.getParentStream().addPairChangeListener(this);
} }

View File

@ -21,7 +21,6 @@ import java.net.*;
import java.time.*; import java.time.*;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.logging.*;
import org.ice4j.*; import org.ice4j.*;
import org.ice4j.attribute.*; import org.ice4j.attribute.*;
@ -29,7 +28,8 @@ import org.ice4j.message.*;
import org.ice4j.socket.*; import org.ice4j.socket.*;
import org.ice4j.stack.*; import org.ice4j.stack.*;
import org.ice4j.util.*; import org.ice4j.util.*;
import org.ice4j.util.Logger; //Disambiguation import org.jitsi.utils.logging2.*;
import org.jitsi.utils.logging2.Logger;
/** /**
* The class that will be generating our outgoing connectivity checks and that * The class that will be generating our outgoing connectivity checks and that
@ -41,17 +41,6 @@ import org.ice4j.util.Logger; //Disambiguation
class ConnectivityCheckClient class ConnectivityCheckClient
implements ResponseCollector implements ResponseCollector
{ {
/**
* The <tt>Logger</tt> used by the <tt>ConnectivityCheckClient</tt>
* 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 java.util.logging.Logger classLogger
= java.util.logging.Logger.getLogger(
ConnectivityCheckClient.class.getName());
/** /**
* The agent that created us. * The agent that created us.
*/ */
@ -114,7 +103,7 @@ class ConnectivityCheckClient
this.parentAgent = parentAgent; this.parentAgent = parentAgent;
this.scheduledExecutorService = scheduledExecutorService; this.scheduledExecutorService = scheduledExecutorService;
this.executorService = executorService; this.executorService = executorService;
logger = new Logger(classLogger, parentAgent.getLogger()); logger = parentAgent.getLogger().createChildLogger(this.getClass().getName());
stunStack = this.parentAgent.getStunStack(); stunStack = this.parentAgent.getStunStack();
} }
@ -195,11 +184,8 @@ class ConnectivityCheckClient
indication, indication,
candidatePair.getRemoteCandidate().getTransportAddress(), candidatePair.getRemoteCandidate().getTransportAddress(),
localCandidate.getBase().getTransportAddress()); localCandidate.getBase().getTransportAddress());
if (logger.isLoggable(Level.FINEST)) logger.trace(() ->
{ "sending binding indication to pair " + candidatePair);
logger.finest(
"sending binding indication to pair " + candidatePair);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -207,11 +193,9 @@ class ConnectivityCheckClient
if (stunSocket != null) if (stunSocket != null)
{ {
logger.log( logger.info("Failed to send " + indication + " through "
Level.INFO, + stunSocket.getLocalSocketAddress() + "\n" +
"Failed to send " + indication + " through " ex.toString());
+ stunSocket.getLocalSocketAddress(),
ex);
} }
} }
} }
@ -282,7 +266,7 @@ class ConnectivityCheckClient
//nominated pairs. //nominated pairs.
if (candidatePair.isNominated()) if (candidatePair.isNominated())
{ {
logger.fine( logger.debug(() ->
"Add USE-CANDIDATE in check for: " "Add USE-CANDIDATE in check for: "
+ candidatePair.toShortString()); + candidatePair.toShortString());
request.putAttribute( request.putAttribute(
@ -326,9 +310,12 @@ class ConnectivityCheckClient
tran.setApplicationData(candidatePair); tran.setApplicationData(candidatePair);
logger.fine( if (logger.isDebugEnabled())
"start check for " + candidatePair.toShortString() + " tid " {
+ tran); logger.debug(
"start check for " + candidatePair.toShortString() + " tid "
+ tran);
}
try try
{ {
tran tran
@ -342,9 +329,9 @@ class ConnectivityCheckClient
originalWaitInterval, originalWaitInterval,
maxWaitInterval, maxWaitInterval,
maxRetransmissions); maxRetransmissions);
if (logger.isLoggable(Level.FINEST)) if (logger.isTraceEnabled())
{ {
logger.finest( logger.trace(
"checking pair " + candidatePair + " tid " + tran); "checking pair " + candidatePair + " tid " + tran);
} }
} }
@ -367,7 +354,7 @@ class ConnectivityCheckClient
msg += " No route to host."; msg += " No route to host.";
ex = null; ex = null;
} }
logger.log(Level.INFO, msg, ex); logger.info(msg + (ex == null ? "" : "\n" + ex.toString()));
} }
} }
@ -407,7 +394,7 @@ class ConnectivityCheckClient
{ {
if (!response.containsAttribute(Attribute.ERROR_CODE)) if (!response.containsAttribute(Attribute.ERROR_CODE))
{ {
logger.fine("Received a malformed error response."); logger.debug(() -> "Received a malformed error response.");
return; //malformed error response return; //malformed error response
} }
@ -528,7 +515,7 @@ class ConnectivityCheckClient
if (!response.containsAttribute(Attribute.XOR_MAPPED_ADDRESS)) if (!response.containsAttribute(Attribute.XOR_MAPPED_ADDRESS))
{ {
logger.fine("Received a success response with no " logger.debug(() -> "Received a success response with no "
+ "XOR_MAPPED_ADDRESS attribute."); + "XOR_MAPPED_ADDRESS attribute.");
logger.info("Pair failed (no XOR-MAPPED-ADDRESS): " logger.info("Pair failed (no XOR-MAPPED-ADDRESS): "
+ checkedPair.toShortString() + ". Local ufrag" + checkedPair.toShortString() + ". Local ufrag"
@ -740,7 +727,7 @@ class ConnectivityCheckClient
} }
else else
{ {
logger.fine( logger.debug(() ->
"Keep alive for pair: " + validPair.toShortString()); "Keep alive for pair: " + validPair.toShortString());
} }
} }
@ -762,7 +749,7 @@ class ConnectivityCheckClient
} }
else else
{ {
logger.fine( logger.debug(() ->
"Keep alive for pair: " + validPair.toShortString()); "Keep alive for pair: " + validPair.toShortString());
} }
} }
@ -832,7 +819,7 @@ class ConnectivityCheckClient
CandidatePair pair CandidatePair pair
= (CandidatePair) ev.getTransactionID().getApplicationData(); = (CandidatePair) ev.getTransactionID().getApplicationData();
logger.finer("Received error code " + ((int) errorCode)); logger.trace(() -> "Received error code " + ((int) errorCode));
//RESOLVE ROLE_CONFLICTS //RESOLVE ROLE_CONFLICTS
if (errorCode == ErrorCodeAttribute.ROLE_CONFLICT) if (errorCode == ErrorCodeAttribute.ROLE_CONFLICT)
@ -840,7 +827,7 @@ class ConnectivityCheckClient
boolean wasControlling boolean wasControlling
= originalRequest.containsAttribute(Attribute.ICE_CONTROLLING); = originalRequest.containsAttribute(Attribute.ICE_CONTROLLING);
logger.finer("Switching to isControlling=" + !wasControlling); logger.trace(() -> "Switching to isControlling=" + !wasControlling);
parentAgent.setControlling(!wasControlling); parentAgent.setControlling(!wasControlling);
pair.getParentComponent().getParentStream().getCheckList() pair.getParentComponent().getParentStream().getCheckList()
@ -950,7 +937,7 @@ class ConnectivityCheckClient
* its final state in either the processResponse(), * its final state in either the processResponse(),
* processTimeout() or processFailure() method. * processTimeout() or processFailure() method.
*/ */
logger.finest("will skip a check beat."); logger.trace(() -> "will skip a check beat.");
checkList.fireEndOfOrdinaryChecks(); checkList.fireEndOfOrdinaryChecks();
} }
} }

View File

@ -17,14 +17,12 @@
*/ */
package org.ice4j.ice; package org.ice4j.ice;
import java.util.logging.*;
import org.ice4j.*; import org.ice4j.*;
import org.ice4j.attribute.*; 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. import org.jitsi.utils.logging2.*;
/** /**
* The class that would be handling and responding to incoming connectivity * The class that would be handling and responding to incoming connectivity
@ -37,17 +35,6 @@ class ConnectivityCheckServer
implements RequestListener, implements RequestListener,
CredentialsAuthority CredentialsAuthority
{ {
/**
* The <tt>Logger</tt> used by the <tt>ConnectivityCheckServer</tt>
* 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 java.util.logging.Logger classLogger
= 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
* same purpose as the <tt>Long.compareUnsigned</tt> method available in * same purpose as the <tt>Long.compareUnsigned</tt> method available in
@ -101,7 +88,7 @@ class ConnectivityCheckServer
public ConnectivityCheckServer(Agent parentAgent) public ConnectivityCheckServer(Agent parentAgent)
{ {
this.parentAgent = parentAgent; this.parentAgent = parentAgent;
logger = new Logger(classLogger, parentAgent.getLogger()); logger = parentAgent.getLogger().createChildLogger(this.getClass().getName());
stunStack = this.parentAgent.getStunStack(); stunStack = this.parentAgent.getStunStack();
stunStack.getCredentialsManager().registerAuthority(this); stunStack.getCredentialsManager().registerAuthority(this);
@ -141,8 +128,7 @@ class ConnectivityCheckServer
public void processRequest(StunMessageEvent evt) public void processRequest(StunMessageEvent evt)
throws IllegalArgumentException throws IllegalArgumentException
{ {
if(logger.isLoggable(Level.FINER)) logger.trace(() -> "Received request " + evt);
logger.finer("Received request " + evt);
alive = true; alive = true;
@ -212,11 +198,9 @@ class ConnectivityCheckServer
} }
catch (Exception e) catch (Exception e)
{ {
logger.log( logger.info("Failed to send " + response
Level.INFO, + " through " + evt.getLocalAddress() + "\n" +
"Failed to send " + response e.toString());
+ " through " + evt.getLocalAddress(),
e);
//try to trigger a 500 response although if this one failed, //try to trigger a 500 response although if this one failed,
//then chances are the 500 will fail too. //then chances are the 500 will fail too.
throw new RuntimeException("Failed to send a response", e); throw new RuntimeException("Failed to send a response", e);
@ -249,11 +233,8 @@ class ConnectivityCheckServer
//extract priority //extract priority
if(priorityAttr == null) if(priorityAttr == null)
{ {
if(logger.isLoggable(Level.FINE)) logger.debug(() -> "Received a connectivity check with"
{ + "no PRIORITY attribute. Discarding.");
logger.log(Level.FINE, "Received a connectivity check with"
+ "no PRIORITY attribute. Discarding.");
}
throw new IllegalArgumentException("Missing PRIORITY attribute!"); throw new IllegalArgumentException("Missing PRIORITY attribute!");
} }
@ -322,7 +303,7 @@ class ConnectivityCheckServer
//role. //role.
else else
{ {
logger.finer( logger.trace(() ->
"Switching to controlled because theirTieBreaker=" "Switching to controlled because theirTieBreaker="
+ theirTieBreaker + " and ourTieBreaker=" + theirTieBreaker + " and ourTieBreaker="
+ ourTieBreaker); + ourTieBreaker);
@ -345,7 +326,7 @@ class ConnectivityCheckServer
//the controlling role. //the controlling role.
if(compareUnsignedLong(ourTieBreaker, theirTieBreaker) >= 0) if(compareUnsignedLong(ourTieBreaker, theirTieBreaker) >= 0)
{ {
logger.finer( logger.trace(() ->
"Switching to controlling because theirTieBreaker=" "Switching to controlling because theirTieBreaker="
+ theirTieBreaker + " and ourTieBreaker=" + theirTieBreaker + " and ourTieBreaker="
+ ourTieBreaker); + ourTieBreaker);

View File

@ -17,11 +17,11 @@
*/ */
package org.ice4j.ice; package org.ice4j.ice;
import org.jitsi.utils.logging2.*;
import java.beans.*; import java.beans.*;
import java.util.*; import java.util.*;
import org.ice4j.util.*;
/** /**
* Implements ice4j internal nomination strategies. * Implements ice4j internal nomination strategies.
* *
@ -30,15 +30,6 @@ import org.ice4j.util.*;
public class DefaultNominator public class DefaultNominator
implements PropertyChangeListener implements PropertyChangeListener
{ {
/**
* 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 java.util.logging.Logger classLogger
= java.util.logging.Logger.getLogger(DefaultNominator.class.getName());
/** /**
* The Agent that created us. * The Agent that created us.
*/ */
@ -71,7 +62,7 @@ public class DefaultNominator
public DefaultNominator(Agent parentAgent) public DefaultNominator(Agent parentAgent)
{ {
this.parentAgent = parentAgent; this.parentAgent = parentAgent;
logger = new Logger(classLogger, parentAgent.getLogger()); logger = parentAgent.getLogger().createChildLogger(this.getClass().getName());
parentAgent.addStateChangeListener(this); parentAgent.addStateChangeListener(this);
} }
@ -117,7 +108,7 @@ public class DefaultNominator
// the component // the component
if (validPair.getParentComponent().getSelectedPair() != null) if (validPair.getParentComponent().getSelectedPair() != null)
{ {
logger.fine( logger.debug(() ->
"Keep-alive for pair: " + validPair.toShortString()); "Keep-alive for pair: " + validPair.toShortString());
return; return;
} }

View File

@ -19,9 +19,10 @@ package org.ice4j.ice;
import java.beans.*; import java.beans.*;
import java.util.*; import java.util.*;
import java.util.logging.Logger;
import org.ice4j.*; import org.ice4j.*;
import org.jitsi.utils.collections.*;
import org.jitsi.utils.logging2.*;
/** /**
* 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
@ -32,15 +33,6 @@ import org.ice4j.*;
*/ */
public class IceMediaStream public class IceMediaStream
{ {
/**
* 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 classLogger =
Logger.getLogger(IceMediaStream.class.getName());
/** /**
* The property name that we use when delivering events notifying listeners * The property name that we use when delivering events notifying listeners
* that the consent freshness of a pair has changed. * that the consent freshness of a pair has changed.
@ -150,7 +142,7 @@ public class IceMediaStream
/** /**
* The {@link Logger} used by {@link IceMediaStream} instances. * The {@link Logger} used by {@link IceMediaStream} instances.
*/ */
private org.ice4j.util.Logger logger; private Logger logger;
/** /**
* Initializes a new <tt>IceMediaStream</tt> object. * Initializes a new <tt>IceMediaStream</tt> object.
@ -161,7 +153,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()); logger = parentAgent.getLogger().createChildLogger(IceMediaStream.class.getName(), JMap.of("name", name));
this.name = name; this.name = name;
this.parentAgent = parentAgent; this.parentAgent = parentAgent;
checkList = new CheckList(this); checkList = new CheckList(this);
@ -182,8 +174,8 @@ public class IceMediaStream
* the stream first. * the stream first.
*/ */
protected Component createComponent( protected Component createComponent(
KeepAliveStrategy keepAliveStrategy, KeepAliveStrategy keepAliveStrategy,
boolean useComponentSocket) boolean useComponentSocket)
{ {
Component component; Component component;
@ -194,7 +186,8 @@ public class IceMediaStream
++lastComponentID, ++lastComponentID,
this, this,
keepAliveStrategy, keepAliveStrategy,
useComponentSocket); useComponentSocket,
logger);
components.put(component.getComponentID(), component); components.put(component.getComponentID(), component);
} }
@ -367,7 +360,7 @@ public class IceMediaStream
orderCheckList(); orderCheckList();
pruneCheckList(checkList); pruneCheckList(checkList);
logger.finest("Checklist initialized."); logger.trace(() -> "Checklist initialized.");
} }
} }
@ -921,4 +914,9 @@ public class IceMediaStream
{ {
return remotePassword; return remotePassword;
} }
public Logger getLogger()
{
return logger;
}
} }

View File

@ -19,12 +19,11 @@ package org.ice4j.ice;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
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. import org.jitsi.utils.logging2.*;
/** /**
* <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
@ -66,7 +65,7 @@ public abstract class LocalCandidate
/** /**
* The {@link Logger} used by {@link LocalCandidate} instances. * The {@link Logger} used by {@link LocalCandidate} instances.
*/ */
private Logger logger; private final Logger logger;
/** /**
* Creates a <tt>LocalCandidate</tt> instance for the specified transport * Creates a <tt>LocalCandidate</tt> instance for the specified transport
@ -91,12 +90,10 @@ public abstract class LocalCandidate
CandidateType type, CandidateType type,
CandidateExtendedType extendedType, CandidateExtendedType extendedType,
LocalCandidate relatedCandidate) LocalCandidate relatedCandidate)
{ {
super(transportAddress, parentComponent, type, relatedCandidate); super(transportAddress, parentComponent, type, relatedCandidate);
logger logger = parentComponent.getLogger().createChildLogger(this.getClass().getName());
= new Logger(classLogger,
parentComponent.
getParentStream().getParentAgent().getLogger());
this.extendedType = extendedType; this.extendedType = extendedType;
} }
@ -205,8 +202,7 @@ public abstract class LocalCandidate
} }
catch (SocketException sex) //don't u just luv da name? ;) catch (SocketException sex) //don't u just luv da name? ;)
{ {
logger.log(Level.SEVERE, logger.error("Failed to acquire Socket"
"Failed to acquire Socket"
+ " specific to STUN communication.", + " specific to STUN communication.",
sex); sex);
exception = sex; exception = sex;
@ -262,8 +258,7 @@ public abstract class LocalCandidate
} }
catch (SocketException sex) //don't u just luv da name? ;) catch (SocketException sex) //don't u just luv da name? ;)
{ {
logger.log(Level.SEVERE, logger.error("Failed to acquire DatagramSocket"
"Failed to acquire DatagramSocket"
+ " specific to STUN communication.", + " specific to STUN communication.",
sex); sex);
exception = sex; exception = sex;

View File

@ -18,13 +18,12 @@
package org.ice4j.socket; package org.ice4j.socket;
import org.ice4j.*; import org.ice4j.*;
import org.jitsi.utils.logging2.*;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.logging.*;
import org.ice4j.util.Logger; //Disambiguation
/** /**
* A {@link DatagramSocket} implementation which merges a set of sockets. * A {@link DatagramSocket} implementation which merges a set of sockets.
@ -44,14 +43,6 @@ import org.ice4j.util.Logger; //Disambiguation
public class MergingDatagramSocket public class MergingDatagramSocket
extends DatagramSocket extends DatagramSocket
{ {
/**
* The {@link Logger} used by the {@link MergingDatagramSocket} class and
* its instances for logging output.
*/
private static final java.util.logging.Logger classLogger
= java.util.logging.Logger.getLogger(
MergingDatagramSocket.class.getName());
/** /**
* Used to control access to {@link #socketContainers}. * Used to control access to {@link #socketContainers}.
*/ */
@ -97,7 +88,7 @@ public class MergingDatagramSocket
/** /**
* The {@link Logger} used by {@link MergingDatagramSocket} instances. * The {@link Logger} used by {@link MergingDatagramSocket} instances.
*/ */
private final Logger logger; protected final Logger logger;
/** /**
* Initializes a new {@link MergingDatagramSocket} instance. * Initializes a new {@link MergingDatagramSocket} instance.
@ -111,14 +102,14 @@ public class MergingDatagramSocket
/** /**
* Initializes a new {@link MergingDatagramSocket} instance. * Initializes a new {@link MergingDatagramSocket} instance.
* @param levelDelegate the {@link Logger} instance which dictates the * @param parentLogger the {@link Logger} parent logger from which we'll
* logging level for the new {@link MergingDatagramSocket} instance. * derive this class' logger instance
* @throws SocketException * @throws SocketException
*/ */
public MergingDatagramSocket(Logger levelDelegate) public MergingDatagramSocket(Logger parentLogger)
throws SocketException throws SocketException
{ {
logger = new Logger(classLogger, levelDelegate); logger = parentLogger.createChildLogger(this.getClass().getName());
} }
/** /**
@ -220,11 +211,8 @@ public class MergingDatagramSocket
public void add(DelegatingSocket socket) public void add(DelegatingSocket socket)
{ {
Objects.requireNonNull(socket, "socket"); Objects.requireNonNull(socket, "socket");
if (logger.isLoggable(Level.FINE)) logger.debug(() -> "Adding a DelegatingSocket instance: "
{ + socket.getLocalAddress());
logger.fine("Adding a DelegatingSocket instance: "
+ socket.getLocalAddress());
}
doAdd(socket); doAdd(socket);
} }
@ -251,11 +239,8 @@ public class MergingDatagramSocket
public void add(DatagramSocket socket) public void add(DatagramSocket socket)
{ {
Objects.requireNonNull(socket, "socket"); Objects.requireNonNull(socket, "socket");
if (logger.isLoggable(Level.FINE)) logger.debug(() -> "Adding a DatagramSocket instance: "
{ + socket.getLocalAddress());
logger.fine("Adding a DatagramSocket instance: "
+ socket.getLocalAddress());
}
doAdd(socket); doAdd(socket);
} }
@ -280,7 +265,7 @@ public class MergingDatagramSocket
{ {
if (indexOf(socketContainers, socket) != -1) if (indexOf(socketContainers, socket) != -1)
{ {
logger.warning("Socket already added."); logger.warn("Socket already added.");
return; return;
} }
@ -361,7 +346,7 @@ public class MergingDatagramSocket
if (socketContainer == active) if (socketContainer == active)
{ {
// TODO: proper selection of a new active socket // TODO: proper selection of a new active socket
logger.warning( logger.warn(
"Removing the active socket. Won't be able to send " "Removing the active socket. Won't be able to send "
+ "until a new one is elected."); + "until a new one is elected.");
active = null; active = null;
@ -369,13 +354,13 @@ public class MergingDatagramSocket
} }
else else
{ {
logger.severe("Cannot find socket to remove."); logger.error("Cannot find socket to remove.");
} }
} }
if (logger.isLoggable(Level.FINE)) if (logger.isDebugEnabled())
{ {
logger.fine("Removed: " + socketContainer); logger.debug("Removed: " + socketContainer);
} }
if (socketContainer != null) if (socketContainer != null)
{ {
@ -595,10 +580,10 @@ public class MergingDatagramSocket
socket = socketWrapper.getUDPSocket(); socket = socketWrapper.getUDPSocket();
} }
if (logger.isLoggable(Level.FINE)) if (logger.isDebugEnabled())
{ {
logger.fine("Initializing the active container, socket=" + socket logger.debug("Initializing the active container, socket=" + socket
+ "; remote address=" + remoteAddress); + "; remote address=" + remoteAddress);
} }
synchronized (socketContainersSyncRoot) synchronized (socketContainersSyncRoot)
@ -611,7 +596,7 @@ public class MergingDatagramSocket
// is not necessarily incorrect. // is not necessarily incorrect.
// Still, go on and replace the active socket with whatever // Still, go on and replace the active socket with whatever
// ICE selected. // ICE selected.
logger.warning("Active socket already initialized."); logger.warn("Active socket already initialized.");
} }
SocketContainer newActive = null; SocketContainer newActive = null;
@ -627,7 +612,7 @@ public class MergingDatagramSocket
if (newActive == null) if (newActive == null)
{ {
logger.severe("No SocketContainer found!"); logger.error("No SocketContainer found!");
return; return;
} }
@ -742,12 +727,9 @@ public class MergingDatagramSocket
+ getLocalSocketAddress() + " -> " + getLocalSocketAddress() + " -> "
+ getRemoteSocketAddress()); + getRemoteSocketAddress());
if (logger.isLoggable(Level.FINE)) logger.debug(() -> "Starting the thread for socket "
{ + getLocalSocketAddress() + " -> "
logger.fine("Starting the thread for socket " + getRemoteSocketAddress());
+ getLocalSocketAddress() + " -> "
+ getRemoteSocketAddress());
}
thread.start(); thread.start();
} }
@ -810,10 +792,7 @@ public class MergingDatagramSocket
// container anymore. // container anymore.
close(true); close(true);
if (logger.isLoggable(Level.FINE)) logger.debug(() -> "Finished: " + toString());
{
logger.fine("Finished: " + toString());
}
} }
/** /**
@ -874,11 +853,7 @@ public class MergingDatagramSocket
synchronized (socketContainersSyncRoot) synchronized (socketContainersSyncRoot)
{ {
MergingDatagramSocket.this.active = this; MergingDatagramSocket.this.active = this;
if (logger.isLoggable(Level.FINE)) logger.debug(() -> "Switching to new active socket: " + this);
{
logger.fine("Switching to new active socket: "
+ this);
}
} }
} }
} }

View File

@ -1,234 +0,0 @@
/*
* 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);
}
}