001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.activemq.transport;
018
019import java.io.IOException;
020
021import org.slf4j.Logger;
022
023/**
024 * Interface for classes that will be called by the TransportLogger
025 * class to actually write to a log file.
026 * Every class that implements this interface has do be declared in
027 * the resources/META-INF/services/org/apache/activemq/transport/logwriters
028 * directory, by creating a file with the name of the writer (for example
029 * "default") and including the line
030 * class=org.apache.activemq.transport.logwriters.(Name of the LogWriter class)
031 * 
032 * @author David Martin Clavo david(dot)martin(dot)clavo(at)gmail.com
033 * 
034 */
035public interface LogWriter {
036
037    /**
038     * Writes a header message to the log.
039     * @param log The log to be written to.
040     */
041    public void initialMessage(Logger log);
042    
043    /**
044     * Writes a message to a log when a request command is sent.
045     * @param log The log to be written to.
046     * @param command The command to be logged.
047     */
048    public void logRequest (Logger log, Object command);
049    
050    /**
051     * Writes a message to a log when a response command is received.
052     * @param log The log to be written to.
053     * @param command The command to be logged.
054     */
055    public void logResponse (Logger log, Object response);
056
057    /**
058     * Writes a message to a log when an asynchronous equest command is sent.
059     * @param log The log to be written to.
060     * @param command The command to be logged.
061     */
062    public void logAsyncRequest (Logger log, Object command);
063    
064    /**
065     * Writes a message to a log when message is sent.
066     * @param log The log to be written to.
067     * @param command The command to be logged.
068     */
069    public void logOneWay (Logger log, Object command);
070    
071    /**
072     * Writes a message to a log when message is received.
073     * @param log The log to be written to.
074     * @param command The command to be logged.
075     */
076    public void logReceivedCommand (Logger log, Object command);
077    
078    /**
079     * Writes a message to a log when an exception is received.
080     * @param log The log to be written to.
081     * @param command The command to be logged.
082     */
083    public void logReceivedException (Logger log, IOException error);
084    
085}