Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Update to Abstraction with new JavaDoc'd classes

...

The approach to logging is that each Entitiy as highlighted on Logging Format Design would provide an implementation of MessageStatusLogger. This logger would be obtained from the MessagesStatusLoggerFactory during the constuction of the entity. When a Status event occured that should be logged a LogActor is requried to request the logging. The initial LogActors would be Connection, Channel and Subscription. Later phases would introduce VirtualHost and ManagementConnection. These Actors provide will initially only be used to provide their log display formated name as per the format design. However, later their details can be used to identify if logging should be procced for that Actor and Entity combination. At this stage selective configurations is not part of this design.

Code Block
java
java
titleLogActor

/**
 * LogActor the entity that is requesting the log to be peformed.
 *
 * The actor is responsible for providing the displayformatted name for the log entry.
 *
 */
public interface LogActor
{
    /**
     * Return the String that this actor wishes to be entered into the logfile.
     *
     * @return String
     */
    public String getLogFormatedNamegetLogFormattedName();
}
Code Block
java
java
titleMessageStatusLogger
/**
 * Message Status messages are logged via this interface.
 *
 * Each Entity that wishes to be logged will implement this to provide their
 * own display representation.
 *
 * The MSLogger will be created by a Factory {@see MessageStatusLoggerFactory}.
 *
 * TheCurrently MessageFactorylogging willhas maintaina aglobal referencesetting tohowever this Loggerwill andlater willbe userevised theand
 * #setEnabled()as tosuch determinethe ifLogActor thiswill loggerneed shouldto be operational.
 *
 * Currently logging has a global setting however this will later be revised and
 * as such the LogActor will need to be taken in to consideration as taken in to consideration as well as the
 * status of this Logger.
 *
 * A detailed and published list of messages that will be logged will be
 * provided so that monitoring systems can know what to expect.
 */
public interface MessageStatusLogger
{
    /**
     * Enable or disable this logger. As controlled by the MessageFactory.
     *
     * @param enabled boolean
     */
    public void setEnabled(boolean enabled); systems can know what to expect.
 */
public interface MessageStatusLogger
{

    /**
     * This method should be used as a guard against expensive message
     * construction prior to calling message().
     *
     * It should not be called if there is no construction required.
     *
     * This will perform validation that the log message should be performed
     * based on the provided Actor and the Entity this Logger represents.
     * This may be done via delegation to the RootMessageStatusLogger.
     *
     * @param actor The actor that is requesting to perform logging
     *
     * @return if this log message should take place
     */
    public boolean isMessageEnabled(LogActor actor);

    /**
     * Logs the message as provided by String.valueOf(message).
     *
     * The call to message() will first check if #isMessageEnabled() allows
     * the logging to be performed. This means for simple messages it is not
     * necessary to guard this call with isMessageEnabled() as it will be called
     * internally.
     *
     * If any complex construction is requried then it MUST BE guarded so that
     * the log message is not needlessly generated.
     *
     * @param actor   The actor that is requesting the logging
     * @param message The message to log
     */
    public void message(LogActor actor, Object message);

    /**
     * Logs the message as provided by String.valueOf(message).
     *
     * The call to message() will first check if #isMessageEnabled() allows
     * the logging to be performed. This means for simple messages it is not
     * necessary to guard this call with isMessageEnabled() as it will be called
     * internally.
     *
     * If any complex construction is requried then it MUST BE guarded so that
     * the log message is not needlessly generated.
     *
     * If the provided Throwable is non-null then the stack trace will also be
     * logged.
     *
     * @param actor   The actor that is requesting the logging
     * @param message The message to log
     * @param throwable The throwable that should be used to generate a trace.
     */
    public void message(LogActor actor, Object message, Throwable throwable);
}

Code Block
java
java
titleMessageStatusLoggerFactory
/**
 * This interface provides a means of creating the Loggers that will be required
 * by each of the entities that have a desire to provide status updates.
 *
 * For new entities to support status logging this interface must be updated.
 *
 * All Loggers defer totto hethe RootMessageStatusLogger as to wither the log should
 * take place.
 */
public interface MessageStatusLoggerFactory
{
    public ConnectionMessageStatusLogger createConnectionMessageStatusLogger(AMQProtocolSession connection);

    public ChannelMessageStatusLogger createChannelMessageStatusLogger(AMQChannel channel);

    public QueueMessageStatusLogger createQueueMessageStatusLogger(AMQQueue queue);

    public ExchangeMessageStatusLogger createExchangeMessageStatusLogger(Exchange exchange);

    public BindingMessageStatusLogger createBindingMessageStatusLogger(ExchangeBinding binding);

    public SubscriptionMessageStatusLogger createSubscriptionMessageStatusLogger(Subscription subscription);

    public MessageStoreMessageStatusLogger createMessageStoreMessageStatusLogger(MessageStore store);
}

Code Block
java
java
titleRootMessageStatusLogger
/**
 * The RootMessageStatusLogger is used by the MessageStatusLoggers to query if
 * logging is enabled for the requested message and to provide the actual
 * message that should be logged.
 */
public interface RootMessageStatusLogger
{
    /**
     * DeterminsDetermin if the MessageStatusLogger and the LogActor should be
     * generating log messages.
     *
     * @param messageStatusLogger The logger performing the logging
     * @param actor               The actor requesting the logging
     * @return boolean true if the message should be logged.
     */
    boolean isMessageEnabled(MessageStatusLogger messageStatusLogger,
                             LogActor actor);

    /**
     * Log the raw message to the configured logger.
     *
     * @param message   The message to log
     * @param throwable Optional Throwable that should provide stact trace
     */
    void rawMessage(String message, Throwable throwable);

    /**
     * Accessor to get the MSLFactory that can then be used to perform logging 
     * @return MessageStatusLoggerFactory 
     */
    MessageStatusLoggerFactory getMessageStatusLoggerFactory();
}

...