jrunx.logger
Class LogEvent

java.lang.Object
  |
  +--jrunx.logger.LogEvent
All Implemented Interfaces:
java.io.Serializable

public class LogEvent
extends java.lang.Object
implements java.io.Serializable

A LogEvent represents a single log message.

Author:
Karl Moss
See Also:
Serialized Form

Field Summary
static java.lang.String DEFAULT_FORMAT
           
protected static java.lang.String lineSeparator
           
static int LOG_DEBUG
           
static int LOG_ERROR
           
static int LOG_INFO
           
static int LOG_METRICS
           
static int LOG_USER
           
static int LOG_WARNING
           
 
Constructor Summary
LogEvent(int type, java.lang.String msg)
          Construct a new LogEvent
LogEvent(int type, java.lang.String msg, java.lang.Throwable t)
          Construct a new LogEvent
LogEvent(int type, java.lang.String msg, java.lang.Throwable t, java.util.Properties props)
          Construct a new LogEvent
 
Method Summary
protected  java.lang.String getExceptionString(java.lang.Throwable t)
           
 java.lang.String getFormat()
          Gets the current format for the event
 java.lang.String getFormattedMessage(java.lang.String f)
          Gets the formatted message.
 java.util.Date getLogTime()
          Gets the time that the message was logged
 java.lang.String getMessage()
          Gets the log message
 java.util.Properties getProperties()
          Gets the additional properties associated with this message, such as metrics information.
 java.lang.Throwable getThrowable()
          Gets the exception associated with this message
 int getType()
          Gets the log event type.
 java.util.Properties getVariables(java.lang.String format)
          Gets the variables for the current log event.
 boolean isDebug()
          Determines if this message is a debug message
 boolean isError()
          Determines if this message is an error message
 boolean isInfo()
          Determines if this message is an informational message
 boolean isMetrics()
          Determines if this message is a metrics message
 boolean isUser()
          Determines if this message is a user message
 boolean isWarning()
          Determines if this message is an warning message
 void setFormat(java.lang.String format)
          Sets the current format for the event
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG_ERROR

public static final int LOG_ERROR

LOG_WARNING

public static final int LOG_WARNING

LOG_INFO

public static final int LOG_INFO

LOG_DEBUG

public static final int LOG_DEBUG

LOG_METRICS

public static final int LOG_METRICS

LOG_USER

public static final int LOG_USER

DEFAULT_FORMAT

public static final java.lang.String DEFAULT_FORMAT

lineSeparator

protected static java.lang.String lineSeparator
Constructor Detail

LogEvent

public LogEvent(int type,
                java.lang.String msg)
Construct a new LogEvent
Parameters:
type - The event type
msg - The message

LogEvent

public LogEvent(int type,
                java.lang.String msg,
                java.lang.Throwable t)
Construct a new LogEvent
Parameters:
type - The event type
msg - The message
throwable - The exception, or null if none

LogEvent

public LogEvent(int type,
                java.lang.String msg,
                java.lang.Throwable t,
                java.util.Properties props)
Construct a new LogEvent
Parameters:
type - The event type
msg - The message
throwable - The exception, or null if none
props - Additional properties for the log event (such as metrics)
Method Detail

getType

public int getType()
Gets the log event type. This method can be used to get custom event types, but the individual is{type} method should be used for standard event types
Returns:
The log type

isError

public boolean isError()
Determines if this message is an error message
Returns:
true if an error message

isWarning

public boolean isWarning()
Determines if this message is an warning message
Returns:
true if a warning message

isInfo

public boolean isInfo()
Determines if this message is an informational message
Returns:
true if an informational message

isDebug

public boolean isDebug()
Determines if this message is a debug message
Returns:
true if a debug message

isMetrics

public boolean isMetrics()
Determines if this message is a metrics message
Returns:
true if a metrics message

isUser

public boolean isUser()
Determines if this message is a user message
Returns:
true if a user message

getMessage

public java.lang.String getMessage()
Gets the log message
Returns:
The message to log

getFormattedMessage

public java.lang.String getFormattedMessage(java.lang.String f)
Gets the formatted message.
Parameters:
format - The format to apply, or null to use the default

getExceptionString

protected java.lang.String getExceptionString(java.lang.Throwable t)

getVariables

public java.util.Properties getVariables(java.lang.String format)
Gets the variables for the current log event. These include: log.level - debug, info, warning, error log.message - the message log.exception - the exception message (if present) log.logger.className - the class name (excluding package) where the log event originated log.logger.fullClassName - the full class name (including package) where the log event originated log.logger.methodName - the method name where the log event originated log.logger.sourceFile - the name of the source file where the log event originated log.logger.line - the line number where the log event originated
Parameters:
format - The logging format, or null to use the default

getThrowable

public java.lang.Throwable getThrowable()
Gets the exception associated with this message
Returns:
The exception to log, or null for none

getProperties

public java.util.Properties getProperties()
Gets the additional properties associated with this message, such as metrics information.
Returns:
The properties, or null for none

setFormat

public void setFormat(java.lang.String format)
Sets the current format for the event
Parameters:
format - The format

getFormat

public java.lang.String getFormat()
Gets the current format for the event
Returns:
The format

getLogTime

public java.util.Date getLogTime()
Gets the time that the message was logged

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright � 2002 Macromedia Corporation. All Rights Reserved.