KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > logging > simple > DecoratedSimpleLog


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 JavaDoc;
21 import java.util.List JavaDoc;
22 import java.text.DateFormat JavaDoc;
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 JavaDoc name) {
38         super(name);
39     }
40
41
42     // ------------------------------------------------------------- Properties
43

44     public DateFormat JavaDoc getDateTimeFormatter() {
45         return (dateFormatter);
46     }
47
48
49     public String JavaDoc getDateTimeFormat() {
50         return (dateTimeFormat);
51     }
52
53
54     public String JavaDoc 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 JavaDoc message, Throwable JavaDoc 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 JavaDoc cache = new ArrayList JavaDoc();
86
87
88     // Clear cache
89
public void clearCache() {
90         cache.clear();
91     }
92
93
94     // Return cache
95
public List JavaDoc getCache() {
96         return (this.cache);
97     }
98
99
100 }
101
Popular Tags