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.logwriters;
018
019import java.io.IOException;
020
021import org.apache.activemq.transport.LogWriter;
022import org.slf4j.Logger;
023
024/**
025 * Implementation of LogWriter interface to keep ActiveMQ's
026 * old logging format.
027 * 
028 * @author David Martin Clavo david(dot)martin(dot)clavo(at)gmail.com
029 * 
030 */
031public class DefaultLogWriter implements LogWriter {
032
033    String prefix = "";
034    @Override
035    public void setPrefix(String prefix) {
036        this.prefix = prefix;
037    }
038
039    // doc comment inherited from LogWriter
040    public void initialMessage(Logger log) {
041        // Default log writer does nothing here
042    }
043
044    // doc comment inherited from LogWriter
045    public void logRequest (Logger log, Object command) {
046        log.debug(prefix + "SENDING REQUEST: "+command);
047    }
048
049    // doc comment inherited from LogWriter
050    public void logResponse (Logger log, Object response) {
051        log.debug(prefix + "GOT RESPONSE: "+response);
052    }
053
054    // doc comment inherited from LogWriter
055    public void logAsyncRequest (Logger log, Object command) {
056        log.debug(prefix + "SENDING ASNYC REQUEST: "+command);
057    }
058
059    // doc comment inherited from LogWriter
060    public void logOneWay (Logger log, Object command) {
061        log.debug(prefix + "SENDING: "+command);
062    }
063
064    // doc comment inherited from LogWriter
065    public void logReceivedCommand (Logger log, Object command) {
066        log.debug(prefix + "RECEIVED: " + command);
067    }
068
069    // doc comment inherited from LogWriter
070    public void logReceivedException (Logger log, IOException error) {
071        log.debug(prefix + "RECEIVED Exception: "+error, error);
072    }
073
074
075}