Home » commons-logging-1.1.1-src » org.apache.commons » logging » simple » [javadoc | source]

    1   /*
    2    * Copyright 2001-2004 The Apache Software Foundation.
    3    * 
    4    * Licensed under the Apache License, Version 2.0 (the "License");
    5    * you may not use this file except in compliance with the License.
    6    * You may obtain a copy of the License at
    7    * 
    8    *      http://www.apache.org/licenses/LICENSE-2.0
    9    * 
   10    * Unless required by applicable law or agreed to in writing, software
   11    * distributed under the License is distributed on an "AS IS" BASIS,
   12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13    * See the License for the specific language governing permissions and
   14    * limitations under the License.
   15    */ 
   16   
   17   package org.apache.commons.logging.simple;
   18   
   19   
   20   import java.util.ArrayList;
   21   import java.util.List;
   22   import java.text.DateFormat;
   23   import org.apache.commons.logging.impl.SimpleLog;
   24   
   25   
   26   /**
   27    * <p>Decorated instance of SimpleLog to expose internal state and
   28    * support buffered output.</p>
   29    */
   30   
   31   public class DecoratedSimpleLog extends SimpleLog {
   32   
   33   
   34       // ------------------------------------------------------------ Constructor
   35   
   36   
   37       public DecoratedSimpleLog(String name) {
   38           super(name);
   39       }
   40   
   41   
   42       // ------------------------------------------------------------- Properties
   43   
   44       public DateFormat getDateTimeFormatter() {
   45           return (dateFormatter);
   46       }
   47   
   48   
   49       public String getDateTimeFormat() {
   50           return (dateTimeFormat);
   51       }
   52   
   53   
   54       public String getLogName() {
   55           return (logName);
   56       }
   57   
   58   
   59       public boolean getShowDateTime() {
   60           return (showDateTime);
   61       }
   62   
   63   
   64       public boolean getShowShortName() {
   65           return (showShortName);
   66       }
   67   
   68   
   69       // ------------------------------------------------------- Protected Methods
   70   
   71   
   72       // Cache logged messages
   73       protected void log(int type, Object message, Throwable t) {
   74   
   75           super.log(type, message, t);
   76           cache.add(new LogRecord(type, message, t));
   77   
   78       }
   79   
   80   
   81       // ---------------------------------------------------------- Public Methods
   82   
   83   
   84       // Cache of logged records
   85       protected ArrayList cache = new ArrayList();
   86   
   87   
   88       // Clear cache
   89       public void clearCache() {
   90           cache.clear();
   91       }
   92   
   93   
   94       // Return cache
   95       public List getCache() {
   96           return (this.cache);
   97       }
   98   
   99   
  100   }

Home » commons-logging-1.1.1-src » org.apache.commons » logging » simple » [javadoc | source]