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