com.adventnet.afp.log
Class LoggerImpl

java.lang.Object
  |
  +--com.adventnet.afp.log.AbstractLogger
        |
        +--com.adventnet.afp.log.LoggerImpl
All Implemented Interfaces:
Logger

public class LoggerImpl
extends AbstractLogger

This class is the default implementation of the Logger interface. The display name is given as custom property. The key name for the display name is DisplayName. The user can give his own property as a custom property (similar to DisplayName)in the Logger properties.

See Also:
Logger

Fields inherited from class com.adventnet.afp.log.AbstractLogger
listeners, loggingLevel
 
Constructor Summary
LoggerImpl()
          Creates a new LoggerImpl instance with the default Logger properties.
 
Method Summary
 void err(java.lang.String message, int level)
          The err method can be used for logging the error messages.
 void err(java.lang.String message, java.lang.Throwable exception, int level)
          The err method can be used for logging the error messages with the exception trace.
 java.lang.String formatMessage(java.lang.String message, int level)
          formatMessage method formats the message to a custom format.
 java.lang.String getDisplayName()
          To get the display name of the Logger.
 LogWriter getLogWriter()
          The getLogWriter method is used to get the LogWriter of the Logger.
 void init(LoggerProperties loggerProps, LogWriter logWriter)
          The init method is used to intialize the logger.
 void out(java.lang.String message, int level)
          The out method can be used for Logging general output messages and debugging messages.
 void setDisplayName(java.lang.String dispName)
          To set the display name of the Logger.
 void setLogWriter(LogWriter logWriter)
          The setLogWriter method is used to assign a LogWriter to the Logger.
 
Methods inherited from class com.adventnet.afp.log.AbstractLogger
addPropertyChangeListener, getInstanceName, getLogLevel, removePropertyChangeListener, setLogLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggerImpl

public LoggerImpl()
Creates a new LoggerImpl instance with the default Logger properties.
Method Detail

init

public void init(LoggerProperties loggerProps,
                 LogWriter logWriter)
          throws LogException
The init method is used to intialize the logger. A logger is active and can handle inputs only after it is initialized.
Overrides:
init in class AbstractLogger
Parameters:
loggerProps - specifies properties of the Logger
logWriter - a LogWriter instance to which the Logger has to be associated.
Throws:
LogException - if an error occurs during initialization

setLogWriter

public void setLogWriter(LogWriter logWriter)
The setLogWriter method is used to assign a LogWriter to the Logger. By changing the LogWriter at runtime, the output from a Logger can be redirected to some other file.
Parameters:
logWriter - a LogWriter instance to which the Logger has to be associated

getLogWriter

public LogWriter getLogWriter()
The getLogWriter method is used to get the LogWriter of the Logger.
Returns:
a LogWriter value

getDisplayName

public java.lang.String getDisplayName()
To get the display name of the Logger. The display name is the name with which the messages from that Logger will be logged.
Returns:
a String value

setDisplayName

public void setDisplayName(java.lang.String dispName)
To set the display name of the Logger.
Parameters:
dispName - a String value

out

public void out(java.lang.String message,
                int level)
The out method can be used for Logging general output messages and debugging messages. The message will be formatted using the formatMessage(java.lang.String, int). The defualt formatting has the time stamp in the format "hh:mm:ss:SSS DisplayName" The message will be logged only if the level of the message is less than or equal to that of the Logger's logging level.
Parameters:
message - String value
level - an int value

err

public void err(java.lang.String message,
                int level)
The err method can be used for logging the error messages. The message will be formatted using the DefaultLogger.formatMessage(java.lang.String, int). The defualt formatting has the time stamp in the format "hh:mm:ss:SSS DisplayName" The message will be logged only if the level of the message is less than or equal to that of the Logger's logging level.
Parameters:
message - String value describing the exception
level - an int logging value

err

public void err(java.lang.String message,
                java.lang.Throwable exception,
                int level)
The err method can be used for logging the error messages with the exception trace. The message will be formatted using the formatMessage(java.lang.String, int). The defualt formatting has the time stamp in the format "hh:mm:ss:SSS DisplayName" The message will be logged only if the level of the message is less than or equal to that of the Logger's logging level.
Parameters:
message - String value describing the exception
exception - a Throwable exception
level - an int logging value

formatMessage

public java.lang.String formatMessage(java.lang.String message,
                                      int level)
formatMessage method formats the message to a custom format. In defualt formatting, the message is prepended with a time stamp in the format "hh:mm:ss:SSS DisplayName". This method can be overridden to get the message in the user-defined format.
Parameters:
message - a String value
level - an int value
Returns:
a String value


Copyright (c)AdventNet Inc., 1996-2004