01: /*
02: * Copyright 2001-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: import java.util.ArrayList;
20: import java.util.List;
21: import java.text.DateFormat;
22: import org.apache.commons.logging.impl.SimpleLog;
23:
24: /**
25: * <p>Decorated instance of SimpleLog to expose internal state and
26: * support buffered output.</p>
27: */
28:
29: public class DecoratedSimpleLog extends SimpleLog {
30:
31: // ------------------------------------------------------------ Constructor
32:
33: public DecoratedSimpleLog(String name) {
34: super (name);
35: }
36:
37: // ------------------------------------------------------------- Properties
38:
39: public DateFormat getDateTimeFormatter() {
40: return (dateFormatter);
41: }
42:
43: public String getDateTimeFormat() {
44: return (dateTimeFormat);
45: }
46:
47: public String getLogName() {
48: return (logName);
49: }
50:
51: public boolean getShowDateTime() {
52: return (showDateTime);
53: }
54:
55: public boolean getShowShortName() {
56: return (showShortName);
57: }
58:
59: // ------------------------------------------------------- Protected Methods
60:
61: // Cache logged messages
62: protected void log(int type, Object message, Throwable t) {
63:
64: super .log(type, message, t);
65: cache.add(new LogRecord(type, message, t));
66:
67: }
68:
69: // ---------------------------------------------------------- Public Methods
70:
71: // Cache of logged records
72: protected ArrayList cache = new ArrayList();
73:
74: // Clear cache
75: public void clearCache() {
76: cache.clear();
77: }
78:
79: // Return cache
80: public List getCache() {
81: return (this.cache);
82: }
83:
84: }
|