JAIN-SIP: updated RI and redirected logs to SC logs

cusax-fix
Sebastien Mazy 17 years ago
parent 372ab97ca0
commit db1056e35b

@ -0,0 +1,233 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.protocol.sip;
import gov.nist.core.*;
import gov.nist.javax.sip.message.*;
import javax.sip.*;
import java.util.*;
import net.java.sip.communicator.util.*;
/**
* 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 Sébastien
*/
public class SipLogger
implements StackLogger,
ServerLogger
{
/**
* All messages will be passed to this logger.
*/
private static final Logger logger
= Logger.getLogger(SipLogger.class);
/*
* Implementation of StackLogger
*/
/**
* log a stack trace. This helps to look at the stack frame.
*/
public void logStackTrace()
{
logger.trace("JAIN-SIP stack trace", new Throwable());
}
public void logStackTrace(int traceLevel)
{
// FIXE ME: don't ignore the level?
logger.trace("JAIN-SIP stack trace", new Throwable());
}
/**
* Get the line count in the log stream.
*
* @return
*/
public int getLineCount()
{
return 0;
}
/**
* Log an exception.
*
* @param ex
*/
public void logException(Throwable ex)
{
logger.warn("Exception in the JAIN-SIP stack: " + ex, ex);
}
/**
* Log a message into the log file.
*
* @param message
* message to log into the log file.
*/
public void logDebug(String message)
{
logger.debug("Debug output from the JAIN-SIP stack: " + message);
}
/**
* Log an error message.
*
* @param message --
* error message to log.
*/
public void logFatalError(String message)
{
logger.trace("Fatal error from the JAIN-SIP stack: " + message);
}
/**
* Log an error message.
*
* @param message --
* error message to log.
*
*/
public void logError(String message)
{
logger.error("Error from the JAIN-SIP stack: " + message);
}
/**
* @return flag to indicate if logging is enabled.
*/
public boolean isLoggingEnabled()
{
return true;
}
/**
* Return true/false if logging is enabled at a given level.
*
* @param logLevel
*/
public boolean isLoggingEnabled(int logLevel)
{
return true;
}
/**
* Log an error message.
*
* @param message
* @param ex
*/
public void logError(String message, Exception ex)
{
logger.error("Error from the JAIN-SIP stack: " + message, ex);
}
/**
* Log a warning message.
*
* @param string
*/
public void logWarning(String string)
{
logger.warn("Warning from the JAIN-SIP stack" + string);
}
/**
* Log an info message.
*
* @param string
*/
public void logInfo(String string)
{
logger.info("Info from the JAIN-SIP stack: " + string);
}
/**
* Disable logging altogether.
*
*/
public void disableLogging() {}
/**
* Enable logging (globally).
*/
public void enableLogging() {}
public void setBuildTimeStamp(String buildTimeStamp)
{
logger.trace("JAIN-SIP RI build " + buildTimeStamp);
}
public void setStackProperties(Properties stackProperties) {}
/*
* Implementation of ServerLogger
*/
public void closeLogFile() {}
public void logMessage(SIPMessage message, String from, String to,
boolean sender, long time)
{
if(sender)
{
logger.trace("JAIN-SIP sent message from \"" + from
+ "\"to \"" + to + "\" at " + time + ":\n"
+ message);
}
else
{
logger.trace("JAIN-SIP received message from \"" + from
+ "\" to \"" + to + "\" at " + time + "\n"
+ message);
}
}
public void logMessage(SIPMessage message, String from, String to,
String status, boolean sender, long time)
{
if(sender)
{
logger.trace("JAIN-SIP sent message from \"" + from
+ "\" to \"" + to + "\" at " + time + " (status: "
+ status + "):\n" + message);
}
else
{
logger.trace("JAIN-SIP received message from \"" + from
+ "\" to \"" + to + "\" at " + time + " (status: "
+ status + "):\n" + message);
}
}
public void logMessage(SIPMessage message, String from, String to,
String status, boolean sender)
{
if(sender)
{
logger.trace("JAIN-SIP sent message from \"" + from
+ "\" to \"" + to + "\" (status: " + status
+ "):\n" + message);
}
else
{
logger.trace("JAIN-SIP received message from \"" + from
+ "\" to \"" + to + "\" (status: " + status
+ "):\n" + message); }
}
public void logException(Exception ex)
{
logger.warn("the following exception occured in JAIN-SIP: " + ex, ex);
}
public void setSipStack(SipStack sipStack) {}
}

@ -36,29 +36,38 @@ public class SipStackProperties
/**
* The name of the property under which the jain-sip-ri would expect to find
* the name of the server log file.
* if the content of the messages (eg SDP) has to be logged
*/
//private static final String NSPNAME_SERVER_LOG
// = "gov.nist.javax.sip.SERVER_LOG";
private static final String NSPNAME_LOG_MESSAGE_CONTENT
= "gov.nist.javax.sip.LOG_MESSAGE_CONTENT";
/**
* The default name of a server log file for the jain-sip RI.
* (not final on purpose, see constructor)
* A string indicating to jain-sip-ri if the content of the messages (eg
* SDP) has to be logged
*/
private static String NSPVALUE_SERVER_LOG = "log/sc-jainsipserver.log";
private static final String NSPVALUE_LOG_MESSAGE_CONTENT = "true";
/**
* The name of the property under which the jain-sip-ri would expect to find
* if the content of the messages (eg SDP) has to be logged
* The name of the property indicating a custom logger class for the stack
*/
//private static final String NSPNAME_LOG_MESSAGE_CONTENT
// = "gov.nist.javax.sip.LOG_MESSAGE_CONTENT";
private static final String NSPNAME_STACK_LOGGER = "gov.nist.javax.sip.STACK_LOGGER";
/**
* A string indicating to jain-sip-ri if the content of the messages (eg
* SDP) has to be logged
* The value of the property indicating a custom logger class for the stack
*/
//private static final String NSPVALUE_LOG_MESSAGE_CONTENT = "true";
private static final String NSPVALUE_STACK_LOGGER = "net.java.sip.communicator.impl.protocol.sip.SipLogger";
/**
* The name of the property indicating a custom logger class
* for the server messages
*/
private static final String NSPNAME_SERVER_LOGGER = "gov.nist.javax.sip.SERVER_LOGGER";
/**
* The value of the property indicating a custom logger class
* for the server messages
*/
private static final String NSPVALUE_SERVER_LOGGER = "net.java.sip.communicator.impl.protocol.sip.SipLogger";
/**
* The name of the property under which the jain-sip-ri would expect to find
@ -176,18 +185,13 @@ public SipStackProperties()
if (!NSPVALUE_DEBUG_LOG.startsWith(logDir))
NSPVALUE_DEBUG_LOG = logDir + NSPVALUE_DEBUG_LOG;
if (!NSPVALUE_SERVER_LOG.startsWith(logDir))
NSPVALUE_SERVER_LOG = logDir + NSPVALUE_SERVER_LOG;
this.setProperty(JSPNAME_STACK_NAME, "Sip Communicator");
// NIST SIP specific properties
this.setProperty(NSPNAME_DEBUG_LOG, NSPVALUE_DEBUG_LOG);
// uncomment the following lines to capture messages in the server log
//this.setProperty(NSPNAME_SERVER_LOG, NSPVALUE_SERVER_LOG);
//this.setProperty(NSPNAME_LOG_MESSAGE_CONTENT,
// NSPVALUE_LOG_MESSAGE_CONTENT);
this.setProperty(NSPNAME_LOG_MESSAGE_CONTENT,
NSPVALUE_LOG_MESSAGE_CONTENT);
this.setProperty(NSPNAME_DEBUG_LOG_OVERWRITE,
NSPVALUE_DEBUG_LOG_OVERWRITE);
@ -258,5 +262,8 @@ else if (logLevel.equals(Level.OFF.getName()))
}
this.setProperty(NSPNAME_TRACE_LEVEL, jainSipTraceLevel);
this.setProperty(NSPNAME_STACK_LOGGER, NSPVALUE_STACK_LOGGER);
this.setProperty(NSPNAME_SERVER_LOGGER, NSPVALUE_SERVER_LOGGER);
}
}

Loading…
Cancel
Save