Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.sip
Class SipLogger

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.sip.SipLogger
All Implemented Interfaces:
gov.nist.core.LogLevels, gov.nist.core.ServerLogger, gov.nist.core.StackLogger

public class SipLogger
extends Object
implements gov.nist.core.StackLogger, gov.nist.core.ServerLogger

This class passes log calls from JAIN-SIP to log4j, so that it is possible to change the log level for the JAIN-SIP stack in logging.properties

Author:
Sebastien Mazy

Field Summary
 
Fields inherited from interface gov.nist.core.LogLevels
TRACE_DEBUG, TRACE_ERROR, TRACE_EXCEPTION, TRACE_FATAL, TRACE_INFO, TRACE_MESSAGES, TRACE_NONE, TRACE_TRACE, TRACE_WARN
 
Constructor Summary
SipLogger()
           
 
Method Summary
 void closeLogFile()
          Dummy implementation for ServerLogger.closeLogFile()
 void disableLogging()
          Disable logging altogether.
 void enableLogging()
          Enable logging (globally).
 int getLineCount()
          Get the line count in the log stream.
 InetSocketAddress getLocalAddressForDestination(InetAddress dst, int dstPort, InetAddress localAddress, String transport)
          Returns a local address to use with the specified TCP destination.
 String getLoggerName()
          Returns a logger name.
 boolean isLoggingEnabled()
          Determines whether logging is enabled.
 boolean isLoggingEnabled(int logLevel)
          Return true/false if logging is enabled at a given level.
 void logDebug(String message)
          Log a message into the log file.
 void logError(String message)
          Log an error message.
 void logError(String message, Exception ex)
          Logs an exception and an error message error message.
 void logException(Exception exception)
          Prints the specified exception as a warning.
 void logException(Throwable ex)
          Log an exception.
 void logFatalError(String message)
          Log an error message.
 void logInfo(String string)
          Log an info message.
 void logMessage(gov.nist.javax.sip.message.SIPMessage message, String from, String to, boolean sender, long time)
          Logs the specified message and details.
 void logMessage(gov.nist.javax.sip.message.SIPMessage message, String from, String to, String status, boolean sender)
          Logs the specified message and details.
 void logMessage(gov.nist.javax.sip.message.SIPMessage message, String from, String to, String status, boolean sender, long time)
          Logs the specified message and details.
 void logStackTrace()
          logs a stack trace.
 void logStackTrace(int traceLevel)
          logs a stack trace.
 void logTrace(String message)
          Logs the specified trace with a debuf level.
 void logWarning(String string)
          Log a warning message.
 void setBuildTimeStamp(String buildTimeStamp)
          Logs the build time stamp of the jain-sip reference implementation.
 void setSipStack(javax.sip.SipStack sipStack)
          A dummy implementation.
 void setStackProperties(Properties stackProperties)
          Dummy implementation for ServerLogger.setStackProperties( Properties)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SipLogger

public SipLogger()
Method Detail

logStackTrace

public void logStackTrace()
logs a stack trace. This helps to look at the stack frame.

Specified by:
logStackTrace in interface gov.nist.core.StackLogger

logStackTrace

public void logStackTrace(int traceLevel)
logs a stack trace. This helps to look at the stack frame.

Specified by:
logStackTrace in interface gov.nist.core.StackLogger
Parameters:
traceLevel - currently unused.

getLineCount

public int getLineCount()
Get the line count in the log stream.

Specified by:
getLineCount in interface gov.nist.core.StackLogger
Returns:
line count

logException

public void logException(Throwable ex)
Log an exception.

Specified by:
logException in interface gov.nist.core.StackLogger
Parameters:
ex - the exception that we are to log.

logDebug

public void logDebug(String message)
Log a message into the log file.

Specified by:
logDebug in interface gov.nist.core.StackLogger
Parameters:
message - message to log into the log file.

logFatalError

public void logFatalError(String message)
Log an error message.

Specified by:
logFatalError in interface gov.nist.core.StackLogger
Parameters:
message - -- error message to log.

logError

public void logError(String message)
Log an error message.

Specified by:
logError in interface gov.nist.core.StackLogger
Parameters:
message - error message to log.

isLoggingEnabled

public boolean isLoggingEnabled()
Determines whether logging is enabled.

Specified by:
isLoggingEnabled in interface gov.nist.core.StackLogger
Returns:
flag to indicate if logging is enabled.

isLoggingEnabled

public boolean isLoggingEnabled(int logLevel)
Return true/false if logging is enabled at a given level.

Specified by:
isLoggingEnabled in interface gov.nist.core.StackLogger
Parameters:
logLevel - the level that we'd like to check loggability for.
Returns:
always true regardless of logLevel's value.

logError

public void logError(String message,
                     Exception ex)
Logs an exception and an error message error message.

Specified by:
logError in interface gov.nist.core.StackLogger
Parameters:
message - that message that we'd like to log.
ex - the exception that we'd like to log.

logWarning

public void logWarning(String string)
Log a warning message.

Specified by:
logWarning in interface gov.nist.core.StackLogger
Parameters:
string - the warning that we'd like to log

logInfo

public void logInfo(String string)
Log an info message.

Specified by:
logInfo in interface gov.nist.core.StackLogger
Parameters:
string - the message that we'd like to log.

disableLogging

public void disableLogging()
Disable logging altogether.

Specified by:
disableLogging in interface gov.nist.core.StackLogger

enableLogging

public void enableLogging()
Enable logging (globally).

Specified by:
enableLogging in interface gov.nist.core.StackLogger

setBuildTimeStamp

public void setBuildTimeStamp(String buildTimeStamp)
Logs the build time stamp of the jain-sip reference implementation.

Specified by:
setBuildTimeStamp in interface gov.nist.core.StackLogger
Parameters:
buildTimeStamp - the build time stamp of the jain-sip reference implementation.

setStackProperties

public void setStackProperties(Properties stackProperties)
Dummy implementation for ServerLogger.setStackProperties( Properties)

Specified by:
setStackProperties in interface gov.nist.core.ServerLogger
Specified by:
setStackProperties in interface gov.nist.core.StackLogger

closeLogFile

public void closeLogFile()
Dummy implementation for ServerLogger.closeLogFile()

Specified by:
closeLogFile in interface gov.nist.core.ServerLogger

logMessage

public void logMessage(gov.nist.javax.sip.message.SIPMessage message,
                       String from,
                       String to,
                       boolean sender,
                       long time)
Logs the specified message and details.

Specified by:
logMessage in interface gov.nist.core.ServerLogger
Parameters:
message - the message to log
from - the message sender
to - the message addressee
sender - determines whether we are the origin of this message.
time - the date this message was received at.

logMessage

public void logMessage(gov.nist.javax.sip.message.SIPMessage message,
                       String from,
                       String to,
                       String status,
                       boolean sender,
                       long time)
Logs the specified message and details.

Specified by:
logMessage in interface gov.nist.core.ServerLogger
Parameters:
message - the message to log
from - the message sender
to - the message addressee
status - message status
sender - determines whether we are the origin of this message.
time - the date this message was received at.

logMessage

public void logMessage(gov.nist.javax.sip.message.SIPMessage message,
                       String from,
                       String to,
                       String status,
                       boolean sender)
Logs the specified message and details.

Specified by:
logMessage in interface gov.nist.core.ServerLogger
Parameters:
message - the message to log
from - the message sender
to - the message addressee
status - message status
sender - determines whether we are the origin of this message.

logException

public void logException(Exception exception)
Prints the specified exception as a warning.

Specified by:
logException in interface gov.nist.core.ServerLogger
Parameters:
exception - the Exception we are passed from jain-sip.

setSipStack

public void setSipStack(javax.sip.SipStack sipStack)
A dummy implementation.

Specified by:
setSipStack in interface gov.nist.core.ServerLogger
Parameters:
sipStack - ignored;

getLoggerName

public String getLoggerName()
Returns a logger name.

Specified by:
getLoggerName in interface gov.nist.core.StackLogger
Returns:
a logger name.

logTrace

public void logTrace(String message)
Logs the specified trace with a debuf level.

Specified by:
logTrace in interface gov.nist.core.StackLogger
Parameters:
message - the trace to log.

getLocalAddressForDestination

public InetSocketAddress getLocalAddressForDestination(InetAddress dst,
                                                       int dstPort,
                                                       InetAddress localAddress,
                                                       String transport)
                                                throws IOException
Returns a local address to use with the specified TCP destination. The method forces the JAIN-SIP stack to create s and binds (if necessary) and return a socket connected to the specified destination address and port and then return its local address.

Parameters:
dst - the destination address that the socket would need to connect to.
dstPort - the port number that the connection would be established with.
localAddress - the address that we would like to bind on (null for the "any" address).
transport - the transport that will be used TCP ot TLS
Returns:
the SocketAddress that this handler would use when connecting to the specified destination address and port.
Throws:
IOException - if we fail binding the local socket

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.