ServerLogpublic class ServerLog extends Object Log file wrapper class.
Log messages into the message trace file and also write the log into the
debug file if needed. This class keeps an XML formatted trace around for
later access via RMI. The trace can be viewed with a trace viewer (see
tools.traceviewerapp). |
Fields Summary |
---|
public static int | TRACE_NONEDont trace | public static int | TRACE_MESSAGESTrace messages. | public static int | TRACE_EXCEPTIONTrace exception processing. | public static int | TRACE_DEBUGDebug trace level (all tracing enabled). | protected static PrintStream | printWriterPrint stream for writing out debug messages. | protected static PrintStream | traceWriterPrint stream for writing out tracing messages. | protected static String | auxInfoAuxililary information to log with this trace. | protected static String | descriptionDesription for mesasge. | protected static String | stackIpAddressStack pointer for mesasge. | protected static int | traceLevelDefault trace level. |
Methods Summary |
---|
public static void | checkLogFile()Checks for valid logging output destination.
// Append buffer to the end of the file.
if (printWriter == null) {
printWriter = traceWriter;
if (printWriter == null) printWriter = System.out;
/*
if (auxInfo != null)
printWriter.println
(" < description\n logDescription = \""+description+
"\"\n name = \"" + stackIpAddress +
"\"\n auxInfo = \"" + auxInfo +
"\"/ > \n ");
else
printWriter.println(" < description\n logDescription = \""
+ description
+ "\"\n name = \""
+ stackIpAddress
+ "\" / > \n");
*/
}
| private static java.lang.String | getStatusHeader(Message message)Gets the status header from the requested message.
// If this message has a "NISTStatus" extension then we extract
// it for logging.
Enumeration statusHeaders = message.getHeaders("NISTExtension");
String status = null;
if (statusHeaders.hasMoreElements()) {
Header statusHdr = (Header) statusHeaders.nextElement();
status = statusHdr.getHeaderValue();
}
return status;
| public static int | getTraceLevel()Gets the trace level for the stack. return traceLevel;
| public static void | logException(java.lang.Exception ex)Logs an exception stack trace.
if (traceLevel >= TRACE_EXCEPTION) {
checkLogFile();
if (printWriter != null) ex.printStackTrace();
}
| public static void | logMessage(Message message, java.lang.String from, java.lang.String to, boolean sender, java.lang.String time)Logs a message into the log directory. Status information is extracted
from the NISTExtension Header.
checkLogFile();
CallIdHeader cid = (CallIdHeader)message.getCallId();
String callId = null;
if (cid != null)
callId = ((CallIdHeader)message.getCallId()).getCallId();
String firstLine = message.getFirstLine();
String inputText = message.encode();
String status = getStatusHeader(message);
String tid = message.getTransactionId();
logMessage(inputText, from, to, sender,
callId, firstLine, status, tid, time);
| public static void | logMessage(Message message, java.lang.String from, java.lang.String to, boolean sender, long time)Logs a message into the log directory.
Status information is extracted from the NISTExtension Header.
checkLogFile();
CallIdHeader cid = (CallIdHeader)message.getCallId();
String callId = null;
if (cid != null) callId = cid.getCallId();
String firstLine = message.getFirstLine().trim();
String inputText = message.encode();
String status = getStatusHeader(message);
String tid = message.getTransactionId();
logMessage(inputText, from, to, sender,
callId, firstLine, status, tid, time);
| public static void | logMessage(Message message, java.lang.String from, java.lang.String to, boolean sender)Logs a message into the log directory. Status information is extracted
from SIPExtension header. The time associated with the message is the
current time.
logMessage(message, from, to, sender,
new Long(System.currentTimeMillis()).toString());
| public static void | logMessage(Message message, java.lang.String from, java.lang.String to, java.lang.String status, boolean sender, java.lang.String time)Logs a message into the log directory.
checkLogFile();
CallIdHeader cid = (CallIdHeader) message.getCallId();
String callId = null;
if (cid != null) callId = cid.getCallId();
String firstLine = message.getFirstLine().trim();
String encoded = message.encode();
String tid = message.getTransactionId();
String shdr = getStatusHeader(message);
if (shdr != null) {
status = shdr + "/" + status;
}
logMessage(encoded, from, to, sender,
callId, firstLine, status, tid, time);
| public static void | logMessage(Message message, java.lang.String from, java.lang.String to, java.lang.String status, boolean sender, long time)Logs a message into the log directory.
checkLogFile();
CallIdHeader cid = (CallIdHeader) message.getCallId();
String callId = null;
if (cid != null) callId = cid.getCallId();
String firstLine = message.getFirstLine().trim();
String encoded = message.encode();
String tid = message.getTransactionId();
String shdr = getStatusHeader(message);
if (shdr != null) {
status = shdr + "/" + status;
}
logMessage(encoded, from, to, sender,
callId, firstLine, status, tid, time);
| public static void | logMessage(Message message, java.lang.String from, java.lang.String to, java.lang.String status, boolean sender)Logs a message into the log directory. Time stamp associated with the
message is the current time.
logMessage(message, from, to, status, sender,
System.currentTimeMillis());
| public static void | logMessage(java.lang.String message)Logs a message into the log file.
// String tname = Thread.currentThread().getName();
checkLogFile();
String logInfo = message;
// printWriter.println(logInfo);
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_JSR180, logInfo);
}
| public static synchronized void | logMessage(java.lang.String message, java.lang.String from, java.lang.String to, boolean sender, java.lang.String callId, java.lang.String firstLine, java.lang.String status, java.lang.String tid, java.lang.String time)Logs a message into the log directory.
MessageLog log = new MessageLog(message, from, to, time,
sender, firstLine, status, tid, callId);
logMessage(log.flush());
| public static synchronized void | logMessage(java.lang.String message, java.lang.String from, java.lang.String to, boolean sender, java.lang.String callId, java.lang.String firstLine, java.lang.String status, java.lang.String tid, long time)Logs a message into the log directory.
MessageLog log = new MessageLog(message, from, to, time,
sender, firstLine,
status, tid, callId);
logMessage(log.flush());
| public static void | logMessage(java.lang.String message, java.lang.String from, java.lang.String to, boolean sender, java.lang.String callId, java.lang.String firstLine, java.lang.String status, java.lang.String tid)Logs a message into the log directory.
String time = new Long(System.currentTimeMillis()).toString();
logMessage
(message, from, to, sender, callId, firstLine, status,
tid, time);
| public static boolean | needsLogging(int logLevel)Checks to see if logging is enabled at a level (avoids
unecessary message formatting.
return traceLevel >= logLevel;
| public static boolean | needsLogging()Global check for whether to log or not. ToHeader minimize the time
return false here.
return traceLevel >= 16;
| public static void | setAuxInfo(java.lang.String auxInfo)Sets aux information. Auxiliary information may be associated
with the log file. This is useful for remote logs.
ServerLog.auxInfo = auxInfo;
| public static void | setDescription(java.lang.String desc)Sets the descriptive String for the log.
description = desc;
| public static void | setLogFileName(java.lang.String loggerURL)Sets the log file name. (need revisit)
| public static void | setTraceLevel(int level)Sets the trace level for the stack.
traceLevel = level;
|
|