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     */ 
017    
018    package org.apache.commons.logging.simple;
019    
020    
021    import java.util.ArrayList;
022    import java.util.List;
023    import java.text.DateFormat;
024    import org.apache.commons.logging.impl.SimpleLog;
025    
026    
027    /**
028     * <p>Decorated instance of SimpleLog to expose internal state and
029     * support buffered output.</p>
030     */
031    
032    public class DecoratedSimpleLog extends SimpleLog {
033    
034    
035        // ------------------------------------------------------------ Constructor
036    
037    
038        public DecoratedSimpleLog(String name) {
039            super(name);
040        }
041    
042    
043        // ------------------------------------------------------------- Properties
044    
045        public DateFormat getDateTimeFormatter() {
046            return (dateFormatter);
047        }
048    
049    
050        public String getDateTimeFormat() {
051            return (dateTimeFormat);
052        }
053    
054    
055        public String getLogName() {
056            return (logName);
057        }
058    
059    
060        public boolean getShowDateTime() {
061            return (showDateTime);
062        }
063    
064    
065        public boolean getShowShortName() {
066            return (showShortName);
067        }
068    
069    
070        // ------------------------------------------------------- Protected Methods
071    
072    
073        // Cache logged messages
074        protected void log(int type, Object message, Throwable t) {
075    
076            super.log(type, message, t);
077            cache.add(new LogRecord(type, message, t));
078    
079        }
080    
081    
082        // ---------------------------------------------------------- Public Methods
083    
084    
085        // Cache of logged records
086        protected ArrayList cache = new ArrayList();
087    
088    
089        // Clear cache
090        public void clearCache() {
091            cache.clear();
092        }
093    
094    
095        // Return cache
096        public List getCache() {
097            return (this.cache);
098        }
099    
100    
101    }